linux下mysql安装
linux下安装MySQL8
cd /usr/local
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-el7-x86_64.tar.gz
tar -zxvf mysql-5.7.23-el7-x86_64.tar.gz
ln -s mysql-5.7.23-el7-x86_64 mysql
cd mysql/
mkdir data
#useradd会自动添加group
useradd mysql
#groupadd mysql
#就当/etc/my.cnf是空的
vim /etc/my.cnf
添加basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
添加
log-error= /usr/local/mysql/mariadb.log
pid-file=/usr/local/mysql/mariadb.pid
添加socket= /usr/local/mysql/mysql.sock
参考
-------------------------------------------
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket= /usr/local/mysql/mysql.sock
server_id = 222
[mysqld_safe]
log-error=/usr/local/mysql/mariadb.log
pid-file=/usr/local/mysql/mariadb.pid
!includedir /etc/my.cnf.d
------------------------------------------
touch /usr/local/mysql/mariadb.log
touch /usr/local/mysql/mariadb.pid
yum -y install libaio [linux最小化安装时 libaio要自己安装]
cd bin
mysqld --user=mysql --initialize
# ./mysqld --user=mysql --initialize
记录rootpassword
##echo 'ibURWsUWt4-S' >> /root/rootpass.txt
chown -R mysql:mysql /usr/local/mysql-5.7.23-el7-x86_64
cp ../support-files/mysql.server /etc/init.d/mysqld
service mysqld start
ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock
登陆并修改密码
./mysql -uroot -p -h127.0.0.1
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
flush privileges;
关闭数据库服务
service mysqld stop
新增所有参数 重新打开数据库服务