Linux下安装MySQL8.0.11的教程
1. 去官网下载安装包
下载链接:点击打开链接
如果你的系统是32位选择第一个,64位选择第二个
也可以用wget 下载
wget https://dev.mysql.com/get/downloads/mysql-8.0/mysql-8.0.11-linux-glibc2.12-i686.tar.gz
解压文件
tar -zxvf mysql-8.0.11-linux-glibc2.12-i686.tar.gz
2 移动压缩包到usr/local目录下,并重命名文件
mv /root/mysql-8.0.11-linux-glibc2.12-i686 /usr/local/mysql
3.在mysql根目录下新建一个文件夹data,用于存放数据
mkdir data
4.创建 mysql 用户组和 mysql 用户
groupadd mysql useradd -g mysql mysql
5.改变 mysql 目录权限
chown -r mysql.mysql /usr/local/mysql/ 或者 chown -r mysql . chgrp -r mysql .
注意最后有一点
6.初始化数据库
创建mysql_install_db安装文件
mkdir mysql_install_db chmod 777 ./mysql_install_db
初始化
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化数据库
或者
/usr/local/mysql/bin/mysqld --initialize --user=mysql /usr/local/mysql/bin/mysqld --initialize --user=mysql /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 5826 [server] a temporary password is generated for root@localhost: twi=tlsi<0o! /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed
记录好自己的临时密码:
twi=tlsi<0o!
这里遇到了问题没有libnuma.so.1
zsh: command not found: mysqld
./bin/mysqld --initialize
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: no such file or directory2018-04-29 17:06:30 [warning] mysql_install_db is deprecated. please consider switching to mysqld --initialize
2018-04-29 17:06:30 [error] can't locate the language directory.
需要安装 libnuma
yum install libnuma yum -y install numactl yum install libaio1 libaio-dev
安装文件
7.mysql配置
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件
vim /etc/my.cnf
[mysqld] basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /usr/local/mysql/mysql.sock character-set-server=utf8 port = 3306 sql_mode=no_engine_substitution,strict_trans_tables [client] socket = /usr/local/mysql/mysql.sock default-character-set=utf8
esc保存
:wq 退出
8建立mysql服务
cp -a ./support-files/mysql.server /etc/init.d/mysqld
cp mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql
添加到系统服务
chkconfig --add mysql
cp -a ./support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/rc.d/init.d/mysqld chkconfig --add mysqld
检查服务是否生效
chkconfig --list mysqld
9. 配置全局环境变量
编辑 / etc/profile 文件
# vi /etc/profile
在 profile 文件底部添加如下两行配置,保存后退出
export path=$path:/usr/local/mysql/bin:/usr/local/mysql/lib export path
设置环境变量立即生效
source /etc/profile
10.启动mysql服务
service mysql start
查看初始密码
cat /root/.mysql_secret
11.登录mysql
mysql -uroot -p密码
修改密码:
set password for 'root'@localhost=password('123456'); #对应的换成你自己的密码即可了。
12设置可以远程登录
mysql>use mysql mysql>update user set host='%' where user='root' limit 1;
刷新权限
mysql>flush privileges;
然后检查3306端口是否开放
netstat -nupl|grep 3306
开放3306端口
firewall -cmd --permanent --add-prot=3306/tcp
重启防火墙
firewall -cmd --reload
总结
以上所述是小编给大家介绍的linux下安装mysql8.0.11的教程,希望对大家有所帮助