新建了一个库怎么修改 数据库名称 、账号、密码

解决方案 »

  1.   

    一、安装设置密码
    我安装的时候直接用的yum命令, yum install mysql mysql-server
    这样就导致默认没有密码访问
    然后我就添加了用户名和密码
    首先以root用户名登录,然后进入没有密码的mysql,
    然后use mysql----------> insert into user(host,user,password) values('%','root',"**************");
    然后mysqladmin -u root password "your password"则OK了
    二、忘记密码
    1,通过service mysqld stop(或者 killall -TERM Mysql)停止mysql的服务
    2,/usr/bin/mysqld_safe --skip-grant-tables&  跳过安全检验机制(此时不要关闭当前终端,另开新的终端)
    3.(也可以进行一:设置密码)
    mysql
    use mysql;
    update user set password=password('自己设置的密码') where user='root';
    (INSERT INTO `user` VALUES ('localhost', 'root', '*6F32271106B4F65F95450A10CD03FC47861EA9CD', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0', '0');)
    flush privileges;
    exit
    4.重启mysql服务
      

  2.   

    grant  select,update,delete,insert on dbname.* to username@'%' identified by 'passwod';
      

  3.   

    因为之前在服务器山装过mysql,在linux的etc下可以查看到my.cnf文件
    只是想该下连接