时间:2021-07-01 10:21:17 帮助过:21人阅读
mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
2、将安装包上传到centos上我安装的目录是在 /usr/local/
1 [root@localhost bin]# cd / 2 [root@localhost /]# cd usr 3 [root@localhost usr]# cd local/ 4 [root@localhost local]# ls 5 bin etc games include lib lib64 libexec sbin share src 6 [root@localhost local]# rz 7 8 [root@localhost local]# ls 9 bin etc games include lib lib64 libexec mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz sbin share src 10 [root@localhost local]# tar -xzvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
3、将压缩包解压:tar -xzvf mysql-5.7.10...
10 [root@localhost local]# tar -xzvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
4、重命名解压后的文件: mv mysql-5.7.10... mysql
1 [root@localhost local]# ls 2 bin games lib libexec mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz share 3 etc include lib64 mysql-5.7.10-linux-glibc2.5-x86_64 sbin src 4 [root@localhost local]# mv mysql-5.7.10-linux-glibc2.5-x86_64 mysql 5 [root@localhost local]# ls 6 bin etc games include lib lib64 libexec mysql mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz sbin share src
5、启动mysql的安装文件
1 [root@localhost mysql]# ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 2 2017-09-28 11:21:54 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 3 2017-09-28 11:21:59 [WARNING] The bootstrap log isn‘t empty: 4 2017-09-28 11:21:59 [WARNING] 2017-09-28T03:21:55.455859Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
注意warning部分:mysql_install_db已经被取代了:
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
6、设置mysql的my.cnf配置 ( 将mysql下的文件复制一份到/etc/目录下 )
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
7、修改my.cnf里面的内容:
1 [mysqld] 2 basedir=/usr/local/mysql 3 datadir=/usr/local/mysql/data 4 port=3306 5 socket=/usr/local/mysql/mysqld.sock 6 7 [client] 8 default-character-set=utf8 9 socket=/usr/local/mysql/mysqld.sock 10 11 [mysql] 12 default-character-set=utf8 13 socket=/usr/local/mysql/mysqld.sock
一开始没有设置mysql的socket,而报
1 ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
设置好socket 就解决了,其实创建软连接也是不错的选择:ln -s /usr/local/mysql/mysqld.sock /tmp/mysql.sock
8、启动mysql :
[root@localhost etc]# service mysqld restart
9、提示修改密码:
1 [root@localhost etc]# mysql 2 ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO) 3 [root@localhost etc]# mysql -uroot -p 4 Enter password:
10、查看mysql的默认密码:
1 [root@localhost ~]# cat /root/.mysql_secret 2 # Password set for user ‘root@localhost‘ at 2017-09-28 11:21:55 3 UQ?x&q+gu#o*
11、用默认密码登录后修改默认密码:
1 mysql> set password = password("root") 2 -> ; 3 Query OK, 0 rows affected, 1 warning (0.00 sec) 4 5 mysql> flush privileges; 6 Query OK, 0 rows affected (0.00 sec) 7 8 mysql> use mysql
然后就可以自己对数据库进行相应的操作了。
Centos6.5安装mysql 5.7
标签:through mysql 创建 sbin load sock nec 默认 自己