网络编程
位置:首页>> 网络编程>> 数据库>> Mysql安装与配置调优及修改root密码的方法

Mysql安装与配置调优及修改root密码的方法

作者:叫我星宇  发布时间:2024-01-15 19:35:06 

标签:mysql,安装,配置,root,密码

一、安装

apt-get install mysql-server 需要设置账号密码


apt-get isntall mysql-client
apt-get libmysqlclient-dev

2.sudo netstat -tap | grep mysql 查看是否安装成功


root@xyz:~# netstat -tap | grep mysql
tcp6    0   0 [::]:mysql       [::]:*         LISTEN   7510/mysqld -->安装成功

二、设置mysql远程访问

1. 编辑mysql配置文件,把其中bind-address = 127.0.0.1注释了


vi /etc/mysql/mysql.conf.d/mysqld.cnf

2. 使用root进入mysql命令行,执行如下2个命令,示例中mysql的root账号密码:root


grant all on *.* to root@'%' identified by 'root' with grant option;
flush privileges;

3. 重启mysql


/etc/init.d/mysql restart

三、MySQL修改root密码的多种方法

方法1: 用SET PASSWORD命令


mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

方法2:用mysqladmin


mysqladmin -u root password "newpass"

如果root已经设置过密码,采用如下方法


mysqladmin -u root password oldpass "newpass"

方法3: 用UPDATE直接编辑user表


mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
  在丢失root密码的时候,可以这样
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;

总结

以上所述是小编给大家介绍的Mysql安装与配置调优及修改root密码的方法网站的支持!

来源:http://www.cnblogs.com/shione/archive/2017/07/28/7249304.html

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com