Install mysql on centos 7

本文档提供了在CentOS 7系统上安装MySQL的详细步骤,并解释了如何找到初始随机设置的root密码,以及如何更改该密码。此外,还介绍了创建新用户、分配权限、允许远程连接及删除用户的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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’;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值