欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MySQL安装_MySQL

程序员文章站 2022-04-29 17:06:54
...
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
相关标签: 安装 二进制