1、linux搭建mysql
下载地址:
http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
xz -d mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
tar -xvf mysql-8.0.16-linux-glibc2.12-x86_64.tar
mv mysql-8.0.16-linux-glibc2.12-x86_64 /usr/local/mysql
mkdir /usr/local/mysql/data
groupadd mysql
useradd mysql -g mysql
chown -R mysql:mysql /usr/local/mysql
yum -y install numactl
yum install -y libaio
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize ###执行后 会有显示初始化的root密码
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on #开机自启
service mysql start #启动
service mysql stop #停止
service mysql restart #重启
/usr/local/mysql/bin/mysql -u root -p ##(-h localhost -P端口 -u root -p 11111 #初始化密码 )
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abc@123'; #修改root密码
ALTER USER 'root'@'%' IDENTIFIED BY 'abc@123' PASSWORD EXPIRE NEVER; #修改root密码永不过期
FLUSH PRIVILEGES;
use mysql;
update user set host='%' where user = 'root'; #修改root用户允许任何ip都可以远程登录
FLUSH PRIVILEGES;
配置my.cnf (/etc/my.cnf)
touch /usr/local/mysql/mysql.err
chown mysql:mysql /usr/local/mysql/mysql.err
----------------------文本内容--------------------------------------
[mysqld]
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/mysql.err
pid-file=/usr/local/mysql/mysql.pid
#skip-grant-tables #如忘记密码 加入这个配置 重启服务 登录(需要在客户端登录)就不需要密码 改完密码再将其注释 再重启服务
----------------------文本内容--------------------------------------
网友评论