Linux云服务环境安装-Mysql8.0篇
(1)进入 cd /usr/local/ ,创建mysql文件夹
mkdir mysql
进入文件夹
(2)下载mysql8.0安装包
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.18-el7-x86_64.tar.gz
拉取成功
(3)进件解压
tar zxvf mysql-8.0.18-el7-x86_64.tar.gz
(4)将mysql-8.0.18-el7-x86_64重命名为 mysql8
(5)将mysql8复制到 /usr/local/目录下
cp -r ./mysql8 /usr/local/
(6)创建data文件夹
mkdir data
(7)分别创建用户组以及用户和密码
groupadd mysql
useradd -r -g mysql mysql
(8)授权用户
chown -R mysql.mysql /usr/local/mysql8
(9)配置 /etc/my.cnf
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql8/
datadir=/usr/local/mysql8/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
lower_case_table_names=1
lc-messages=en_US
lc-messages-dir=/usr/local/mysql8/share/english/
(10)进入mysql8文件夹下的bin目录下 -------------初始化基础信息
./mysqld --user=mysql --basedir=/usr/local/mysql8/–datadir=/usr/local/mysql8/data/–lower-case-table-names=1 --initialize
获得初始密码
(11)返回上一级目录,添加mysqld服务到系统
cd ..
cp -a ./support-files/mysql.server /etc/init.d/mysql
(12)授权以及添加服务
chmod +x /etc/init.d/mysql
chkconfig --add mysql
(13)启动mysql
service mysql start
查看启动状态
service mysql status
(14)将mysql命令添加到服务
ln -s /usr/local/mysql8/bin/mysql /usr/bin
(15)登录mysql -uroot -p
mysql -uroot -p
如果报错 mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
执行此命令 -------------没有报错跳过
yum install libncurses*
登录成功,可以修改密码
ALTER USER USER() IDENTIFIED BY '你的密码';
进行刷新
flush privileges;
(16)进入数据库,配置对外开放
use mysql;
select host from user where user = 'root';
update user set host = '%' where user = 'root'
修改完刷新应用
flush privileges;
修改成功
连接成功