MySQL安装步骤
下载
mysql.tar.gz下载
安装
groupadd mysql
useradd -r -g mysql mysql
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.24 /usr/local/mysql
mkdir /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
初始化
/usr/local/mysql/support-files/mysql.server start
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
mysql -u root -p
set password for root@localhost = password('admin');
use mysql
update user set user.Host='%' where user.User='root';
flush privileges;
开机自启
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
忘记密码
service mysql stop
skip-grant-tables
mysql -u root
use mysql
update mysql.user set authentication_string=password('admin') where user='root';
flush privileges;
|