先
删除本地
# rpm -qa | grep mysql
删除老版本:rpm -e --nodeps mysql-libs-5.1.52-1.el6_0.1.x86_64
直接安装:
rpm -ivh MySQL-server-5.6.13-1.el6.x86_64.rpm --replacefiles
rpm -ivh MySQL-client-5.6.13-1.el6.x86_64.rpm --replacefiles
rpm -ivh MySQL-client-5.6.13-1.el6.x86_64.rpm --replacefiles
查看MYSQL初始密码: cat /root/.mysql_secret
查看数据为是否启动:netstat -nat ;
看看是否有3306端口的应用,如果没有,执行以下语句:
启动数据库:service mysql start;
关闭数据库: /etc/init.d/mysql stop
登录启动:
mysql -u root -p
enter password:输入密码
有时会出现如下错误,怎么都连不上
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
这时要用安全模式登录系统修改初始密码,步骤如下:
1、关闭数据库
2、另起一个SSH,登录到系统,开启安全模式,命令: /usr/bin/mysqld_safe --skip-grant-tables
3、用另一个SSH,修改密码:
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
重启数据库,登录
# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password:
CREATE USER tuser1 IDENTIFIED BY “123456”
GRANT ALL PRIVILEGES ON *.* TO 'tuser1'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'tuser1'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
个别数据库授权
mysql>create database phplampDB;
//授权phplamp用户拥有phplamp数据库的所有权限。
>grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';
//刷新系统权限表
mysql>flush privileges;
//授权phplamp用户拥有phplamp数据库的所有权限。
>grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';
//刷新系统权限表
mysql>flush privileges;