1.下载
mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz
2.解压
tar -xvf mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.15-linux-glibc2.12-x86_64 mysql
mv mysql /usr/local
cd /usr/local/mysql
mkdir data
3.编辑 my.cnf
vi /etc/my.cnf
文件内容为:
[client] port=3306 socket=/tmp/mysql/mysql.sock [mysqld] port=3306 user=mysql socket=/tmp/mysql/mysql.sock basedir=/usr/local/mysql datadir=/usr/local/mysql/data log-error=error.log transaction_isolation = READ-COMMITTED character-set-server = utf8mb4 collation-server = utf8mb4_general_ci lower_case_table_names = 1 #skip-grant-tables
4.创建用户
groupadd mysql
useradd -g mysql mysql
5.更改目录权限
chown -R mysql:mysql /tmp/mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /tmp/mysql /usr/local/mysql
6. 初始化
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
7.初始化密码
初始化时并没有出现 初始密码,因此需要修改密码。
注释 skip-grant-tables,可以使用无密码登录
启动 mysql
./support-files/mysql.server start
1.清空密码
use mysql;
update user set authentication_string=‘‘ where user=‘root‘;
2.无密码登录
mysql -u root -p
输入密码是直接回车。
ALTER user ‘root‘@‘localhost‘ IDENTIFIED BY ‘root‘;
这样就修改好密码了。
自此 mysql 就安装好了。
原文地址:https://www.cnblogs.com/yg_zhang/p/10424926.html