Install mysql on centos 7

来源:互联网 发布:张敬轩关智斌 知乎 编辑:程序博客网 时间:2024/04/29 12:06

install

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

注意

after:

sudo yum install mysql-serversudo systemctl start mysqldmysql -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’;
0 0
原创粉丝点击