之前安装MySQL是通过编译的方式安装《编译安装mysql》,此次不进行编译,直接安装。
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
[root@hk tools]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz [root@hk tools]# tar zxf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz [root@hk tools]# mv mysql-5.6.16-linux-glibc2.5-x86_64 /opt/ [root@hk opt]# mv mysql-5.6.16-linux-glibc2.5-x86_64 mysql [root@hk opt]# /usr/sbin/useradd mysql -s /sbin/nologin -M [root@hk opt]# cd mysql/ [root@hk mysql]# /opt/mysql/scripts/mysql_install_db --basedir=/opt/mysql/ --datadir=/opt/mysql/data --user=mysql [root@hk mysql]# mv /etc/my.cnf /etc/my.cnf.backup [root@hk mysql]# sed -i 's#\# socket = .....# socket = /tmp/mysql.sock#g' my.cnf [root@hk mysql]# cp /opt/mysql/my.cnf /etc/my.cnf [root@hk mysql]# /opt/mysql/support-files/mysql.server start [root@hk mysql]# netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 :::3306 :::* LISTEN 28104/mysqld [root@hk mysql]# /opt/mysql/bin/mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) #看下面的sock的配置 [root@hk mysql]# sed -i 's#\# socket = .....# socket = /tmp/mysql.sock#g' my.cnf [root@hk mysql]# /opt/mysql/bin/mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) #居然报错 [root@hk mysql]# /opt/mysql/bin/mysqld_safe --skip-grant-tables & [1] 30062 mysql> update mysql.user set password=PASSWORD('admin123') where user='root'; #设置密码 mysql> flush privileges; [root@hk mysql]# skill 30194 [root@hk mysql]# 140601 00:14:38 mysqld_safe mysqld from pid file /opt/mysql/data/hk.t4x.org.pid ended [1]+ Done /opt/mysql/bin/mysqld_safe --skip-grant-tables [root@hk mysql]# /opt/mysql/bin/mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) #错误依旧 [root@hk mysql]# vim /usr/local/mysql/support-files/mysql.server #配置文件中默认配置目录是/usr/local/mysql [root@hk mysql]# ln -s /opt/mysql /usr/local/mysql #设置软连接 [root@hk mysql]# /usr/local/mysql/bin/mysql -uroot -p'admin123' mysql> |
申明:本文由BYRD原创(基于Mysql5.6.16),未经许可禁止转载! SourceByrd's Weblog-https://note.t4x.org/database/mysql-linux-glibc/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks