mysql5.6安装以及密码重置

mysql卸载文章:http://hi.baidu.com/cosphp/item/c18c5c88ed3a71ead1f8cdf1
查看是否有旧版本mysql
rpm -qa|grep mysql
CentOS卸载旧版本mysql
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /data/soft/mysql/*
rm /etc/my.cnf.rpmsave
删除mysql服务
chkconfig --list | grep -i mysql
chkconfig --del mysql
删除分散mysql文件夹
whereis mysql 或者 find / -name mysql
安装cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -zxvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
gmake
gmake install
下载mysql安装包进行安装
wget http://dev.mysql.com/get/archives/mysql-5.6/mysql-5.6.11.tar.gz
tar zxvf mysql-5.6.11.tar.gz
cd mysql-5.6.11.tar.gz
cmake . -DCMAKE_INSTALL_PREFIX=/data/soft/mysql -DMYSQL_DATADIR=/data/dbdata -DSYSCONFDIR=/data/soft/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0 -DMYSQL_TCP_PORT=3306 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=yes
make
make install
生成配置文件链接
cp /data/soft/mysql/support-files/my-default.cnf /data/soft/mysql/my.cnf
cp /data/soft/mysql/support-files/my-default.cnf /etc/my.cnf
修改$PATH生成文件
vim /etc/profile
最后一行加上
PATH=$PATH:/data/soft/mysql/bin
这样MySQL的命令行软件就可以直接使用了
复制mysql的服务shell文件
cp /data/soft/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
创建MySQL系统数据库
/data/soft/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/soft/mysql --datadir=/data/dbdata
开启MySQL服务
service mysqld start
设置MySQL开机启动
echo "service mysqld start" >> /etc/rc.local
到这里mysql安装完成了, 我们开始使用客户端连接mysql
登录并修改MySQL的root密码
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> USE mysql ;
Database changed
mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit

posted @ 2017-05-03 10:07  醉客剑轩  阅读(1182)  评论(0编辑  收藏  举报