当前位置:Gxlcms > mysql > MySQL安装_MySQL

MySQL安装_MySQL

时间:2021-07-01 10:21:17 帮助过:34人阅读

bitsCN.com

Install on Linux

采用二进制方式安装

# 建立用户和组
shell> groupadd mysql
shell> useradd -r -g mysql -d /home/mysql -s /bin/bash mysql
# 解压安装
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
# 初始化数据库
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

# 启动和停止
shell> bin/mysqld_safe --user=mysql &
shell> bin/mysqladmin -uroot shutdown

# 设置root密码
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

# 或者用update语句设置密码
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
bitsCN.com

人气教程排行