Install mysql on centos 7

install

参照这篇教程:
https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-7

注意

after:

sudo yum install mysql-server
sudo systemctl start mysqld
mysql -u root -p

以前默认mysql的root密码为空,但是现在的版本有个随机密码(具体原因我也不知道,有知道的请给我留言),这个密码通过下面语句查看:

shell> sudo grep 'temporary password' /var/log/mysqld.log

说明:

At the initial start up of the server, the following happens, given that the data directory of the server is empty:
The server is initialized.
An SSL certificate and key files are generated in the data directory.
The validate_password plugin is installed and enabled.
A superuser account ‘root’@’localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
shell> sudo grep ‘temporary password’ /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;

详情见官方文档:http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

create new user

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;

允许远程登录

CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';

Drop user

DROP USER ‘demo’@‘localhost’;

你可能感兴趣的:(linux,mysql,centos,mysql)