> 数据库 > MySQL >

阿里云里的mysql安装

今天又整里下mysql安装,卸载先:


[root@ora11g ~]# rpm -qa |grep -i mysql
MySQL-server-5.6.12-1.linux_glibc2.5
[root@ora11g ~]# rpm -e MySQL-server-5.6.12-1.linux_glibc2.5
由于rpm –e并不会卸载mysql的数据库,需要手动rm删除掉。
[root@ora11g ~]# ls -l /var/lib/mysql/

[root@ora11g ~]# rm -rf /var/lib/mysql/

安装mysql服务端rpm包
[root@ora11g ~]# rpm -ivh MySQL-server-5.6.12-1.linux_glibc2.5.x86_64.rpm

 

启动之后,老是爆:

The server quit without updating PID file (/var/lib/mysql/AY1403301919063486b3Z.pid)

。照网上的教程解决不了。

后来发现时swapon没开启(至于怎么创建swap分区,实在不记得了)

于是

>swapon /tmp/swapfile

>service mysql start

搞定!!

后来遇到 密码问题


 [root@ora11g mysql]# mysql -u root
mysql: Unknown OS character set 'GB18030'.
mysql: Switching to the default character set 'latin1'.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

记得安装mysql 5.5的版本mysql默认的密码都是空的,也就是root没有设置密码,看来在mysql 5.6之后有了改变 。

Mysql server的rpm安装中有这么一段话,看来密码随机生成到/root/.mysql_secret文件中了
2013-06-26 10:19:39 11874 [Note] InnoDB: 5.6.12 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.

[root@ora11g ~]# less /root/.mysql_secret
# The random password set for the root user at Wed Jun 26 10:19:41 2013 (local time): qG0hZOc

再次登录mysql server
[root@ora11g mysql]# mysql -u root -p
Enter password:

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

而比较奇怪的是需要先设置PASSWORD才能执行命令
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> set PASSWORD=PASSWORD('root');

或者
update user set password=password('root') where user='root';

(责任编辑:IT)