二进制 mysql 的安装步骤
一、安装 mysql:# yum -y install gcc glibc libaio libstdc++ libstdc ncurses-libs
# yum install gcc gcc-c++
# yum install ncurses ncurses-devel
# mkdir -p /usr/local/src
# cd /usr/local/src
# rz+软件名
# tar xf mysql-5.7.17-linux-glibc2.5-i686.tar.gz
# useradd mysql -s /sbin/nologin -M
# mv mysql-5.7.17-linux-glibc2.5-i686/usr/local/mysql
# cd /usr/local/mysql
#ln -s mysql-5.7.17-linux-glibc2.5-i686 mysql
# chown -R mysql .
# chgrp -R mysql .
# bin/mysqld --initialize --user=mysql#生成的密码要记住:root@localhost: 1daeiqUjJL_q
# chown -R root .
# mkdir -p /usr/local/mysql/data
#chown -R mysql data
# bin/mysqld_safe --user=mysql &
# cp support-files/mysql.server /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig --level 2345 mysql on
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig mysqld on
# service mysqld start
Starting MySQL.. SUCCESS!
# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
二、添加环境变量:
# vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
# source /etc/profile
补充:通过配置my.cnf mysql选项socket文件位置解决
# service mysqld stop
Shutting down MySQL.. SUCCESS!
# vim /etc/my.cnf
在最后增加即可:
no-auto-rehash
socket = /var/lib/mysql/mysql.sock
# service mysqld start
Starting MySQL.. SUCCESS!
# mysql -uroot -p
三、访问数据库,用安装时给的随机密码进行第一次登录:
# mysql -uroot -p
四、怎么修改 mysql 数据库的随机密码
mysql> set password for 'root'@localhost = password ('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection> Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>
页:
[1]