mkdir -p /data/mysql
1.下载
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
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
3.编辑 my.cnf
vi /etc/my.cnf
文件内容为:
按 Ctrl+C 复制代码
[client]
port=3306
socket=/data/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
按 Ctrl+C 复制代码
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
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lower-case-table-names=1
修改 vim /etc/my.conf
[mysqld_safe]
#log-error=/data/mysql/logs/mariadb.log
#pid-file=/data/mysql/logs/mariadb.pid
7.初始化密码
初始化时并没有出现 初始密码,因此需要修改密码。
注释 skip-grant-tables,可以使用无密码登录
启动 mysql
./support-files/mysql.server start
全局MySQL设置
ln -s /data/mysql/bin/mysql /usr/bin
1.清空密码
use mysql;
update user set authentication_string=’’ where user=‘root’;
2.无密码登录
mysql -u root -p
输入密码是直接回车。
ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘root’;
这样就修改好密码了。
刷新权限
FLUSH PRIVILEGES;
自此 mysql 就安装好了。
8 设置自动启动
cd support-files/
cp mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
cd /etc/init.d
chkconfig --add mysql
chkconfig --level 345 mysql on
mysql restart
1.在 my.cnf 的mysqld 下增加
default_authentication_plugin=mysql_native_password
2.进入mysql命令行
use mysql
update user set host =’%’ where user=‘root’;
ALTER USER root@’%’ IDENTIFIED WITH mysql_native_password BY ‘password’;
FLUSH PRIVILEGES;
使用客户端工具进行连接。
8.0修改密码
alter user ‘root’@‘localhost’ IDENTIFIED BY ‘password.’;
远程权限
use mysql;
update user set host="%" where user=“root”;
flush privileges;
navicat 不能连接
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘password.’; #修改加密规则
ALTER USER ‘root’@’%’ IDENTIFIED BY ‘password.’ PASSWORD EXPIRE NEVER; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限
mysqldump 软连接设置
ln -fs /data/mysql/bin/mysqldump /usr/bin
ln -fs /data/mysql/bin/mysql /usr/bin