1: 先卸载掉老版本的mysql
(linux严格区分大小写,查找的时候加上-i参数,和mysql相关的全部要卸)
[root@liuchao soft]# rpm -qa | grep -i mysql
mysql-libs-5.1.66-2.el6_3.x86_64
2:如果卸载不掉,就强制卸载,有多少mysql包就卸载多少
在命令后面加上–nodeps
[root@liuchao soft]# rpm -e mysql-libs-5.1.66-2.el6_3.x86_64 –nodeps
3:安装mysql
root@liuchao soft]# rpm -ivh MySQL-devel-5.6.10-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@liuchao soft]# rpm -ivh MySQL-client-5.6.10-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@liuchao soft]# rpm -ivh MySQL-server-5.6.10-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-server ########################################### [100%]
4:启动
[root@liuchao soft]# service mysql start
Starting MySQL..[ OK ]
5:mysql密码
先查看.mysql_secret文件,最后面的串就是root的初始登陆密码(aVqC5xqi)
[root@liuchao soft]# cat /root/.mysql_secret
The random password set for the root user at Fri Mar 20 19:00:58 2015 (local time): aVqC5xqi
6:登陆
[root@liuchao ~]# mysql -uroot -p
Enter password: 这里输入上面的密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.10
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql>
7:提示修改密码才可以登陆
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
修改密码
mysql> set password = password(‘123456’);
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
8:然后再登陆
[root@liuchao ~]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+
4 rows in set (0.01 sec)
mysql>
9:ok,成功了
10:Navicat 8 for MySQL 连接(报错,这是因为需要远程登陆授权)
1103 - Host ‘192.168.6.46’ is not allowed to connection to this MySQL
server
11:远程登陆授权
mysql -u root -p123456(先在终端登陆)
mysql>use mysql;
mysql>update user set host = ‘%’ where user = ‘root’;
mysql>flush privileges;
然后退出重启一下mysql就行了
12:在执行update user set host = ‘%’ where user = ‘root’;报错
mysql> update user set host = ‘%’ where user = ‘root’;
ERROR 1062 (23000): Duplicate entry ‘%-root’ for key ‘PRIMARY’
那就直接执行下面的命令
mysql>flush privileges;
然后退出重启mysql就行了
13:安装完之后启动报错
Starting MySQL..The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid
查看vi /etc/my.cnf
里面的东西比较多(不知道因为哪个设置报错)
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
default-storage-engine = MyISAM
innodb = OFF
skip-innodb
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin = mysql-bin
binlog_format = mixed
server-id = 1
[mysqldump]
quick
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
14:解决办法(删除/etc/my.cnf重新建立my.cnf 用下面的设置就可以了)
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
15:navicat for Mysql连接报错
2003 - Cat’t connect to MySQL server on ‘???’ (10065)
解决办法(关闭防火墙)[root@liuchao ~]# service iptables stop
iptables: Flushing firewallrules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
再重新登陆