温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL8.0安装

发布时间:2020-08-11 11:11:57 来源:ITPUB博客 阅读:136 作者:甲骨文技术支持 栏目:MySQL数据库


0.环境:

os : CentOS release 6.10 (Final)

Msyql: mysql8.0.14


1.下载官方打包好的二进制安装包:


#wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.14-linux-glibc2.12-x86_64.tar.xz


8.0采用了新的.xz压缩方式,文件很小,只有350M左右


2.解压:

tar -xJvf mysql-8.0.14-linux-glibc2.12-x86_64.tar.xz


3.放到/usr/local下


[root@iceman local]# ln -s mysql-8.0.14-linux-glibc2.12-x86_64 mysql


4.配置参数文件 /etc/my.cnf


[mysqld]

server-id                      = 1

port                           = 3306

datadir                        = /data/mysql

socket                         = /tmp/mysql.sock

pid-file                       = /tmp/mysqld.pid

log-error                      = error.log

slow-query-log                 = 1

slow-query-log-file            = slow.log

long_query_time                = 0.2

log-bin                        = bin.log

binlog_format                 =ROW

character-set-client-handshake = FALSE

character-set-server           = utf8mb4

collation-server               = utf8mb4_unicode_ci

init_connect                   ='SET NAMES utf8mb4'

innodb_buffer_pool_size        = 200M

join_buffer_size               = 10M

sort_buffer_size               = 2M

read_rnd_buffer_size           = 2M

log_timestamps                 = SYSTEM


5.创建用户和目录

[root@iceman ~]# groupadd mysql

[root@iceman ~]# useradd -r -g mysql -s /bin/false mysql   ### /bin/false的意思是,禁止一起登录行为

[root@iceman ~]# mkdir -p /data/mysql

[root@iceman ~]# chown -R mysql:mysql /data/mysql/

[root@iceman ~]# chmod -R 775 /data/mysql/


6.初始化数据库:可以用--initialize-insecure不生成密码

[root@iceman bin]# pwd

/usr/local/mysql/bin

[root@iceman bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql


初始化的时候遇到如下两个问题,用Yum 安装上即可。


./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

yum -y install libaio


./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

yum -y install numactl


7.设置启动文件:

#cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql

--启动数据库:

# /etc/init.d/mysql start

Starting MySQL.Logging to '/data/mysql/error.log'.

 SUCCESS! 


8.修改环境变量


# vim /etc/profile.d/mysql.sh

export PATH=$PATH:/usr/local/mysql/bin


# source /etc/profile.d/mysql.sh 


9 .修改密码

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> 

mysql> 

mysql> alter user root@localhost identified by 'Hellxxxeiyun!@#$';

Query OK, 0 rows affected (0.01 sec)


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI