当前位置:Gxlcms > mysql > mysql安装及root密码初始化_MySQL

mysql安装及root密码初始化_MySQL

时间:2021-07-01 10:21:17 帮助过:22人阅读

bitsCN.com
安装mysql [root@sample ~]# yum -y install mysql-server  ← 安装MySQL[root@sample ~]# yum -y install php-mysql  ← 安装php-mysql配置mysql [root@sample ~]# /etc/init.d/mysqld stop 停止mysql服务[root@sample ~]# vim /etc/my.cnf mysql服务的配置文件[mysqld] datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security risksskip-grant-tables #添加这句话,这时候登入mysql就不需要密码symbolic-links=0 [root@sample ~]# /etc/init.d/mysqld start 启动mysql服务[root@sample ~]# mysql 登入mysqlmysql> USE mysql ;mysql> UPDATE user SET Password = password(‘new-password‘) WHERE User = ’root’ ;mysql> flush privileges ; mysql> quit在把 /etc/my.cnf 中 skip-grant-tables 注释了,恢复配置文件原样。 [root@sample ~]# /etc/init.d/mysqld restart 启动mysql服务 [root@sample ~]# mysql -u root -p 输入密码 修改密码 原来的帐号:root,密码:root,修改成 fire [root@sample ~]# mysqladmin -u root -p password fire Enter password:
bitsCN.com

人气教程排行