Centos 安装 MySQL

本文介绍如何使用yum安装MySQL及其服务,并提供了启动服务的方法。还详细解释了如何设置MySQL的初始及后续密码,允许root用户远程连接数据库的具体步骤,以及如何设置MySQL开机启动。

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

安装
yum install mysql mysql-server
启动
service mysqld start

启动提示如下

Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h iZ2ze4ix88haxa5rspk7mwZ password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

首次密码设置命令
mysqladmin -u root -p 密码

更改密码命令
mysqladmin -u root -p password 新密码
命令回车后会问你旧密码

mysql默认只允许本地用户连接,开启远程连接方法:
允许root用户允许远程连接mysql数据库
grant all privileges on *.* to 'root'@'%' identified by 'root的密码' with grant option;
flush privileges;

设置开机启动mysql
systemctl enable mysqld
查看mysql 当前状态
systemctl status mysqld

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值