您的位置:首页 > 数据库 > MySQL

二进制 mysql 的安装步骤

2017-02-24 12:32 253 查看
一、安装 mysql:[root@localhost ~]# yum -y install gcc glibc libaio libstdc++ libstdc ncurses-libs[root@localhost ~]# yum install gcc gcc-c++[root@localhost ~]# yum install ncurses ncurses-devel[root@localhost ~]# mkdir -p /usr/local/src[root@localhost ~]# cd /usr/local/src[root@localhost src]# rz+软件名[root@localhost src]# tar xf mysql-5.7.17-linux-glibc2.5-i686.tar.gz[root@localhost src]# useradd mysql -s /sbin/nologin -M[root@localhost src]# mv mysql-5.7.17-linux-glibc2.5-i686 /usr/local/mysql[root@localhost src]# cd /usr/local/mysql[root@localhost mysql]# ln -s mysql-5.7.17-linux-glibc2.5-i686 mysql[root@localhost mysql]# chown -R mysql . [root@localhost mysql]# chgrp -R mysql . [root@localhost mysql]# bin/mysqld --initialize --user=mysql #生成的密码要记住:root@localhost: 1daeiqUjJL_q [root@localhost mysql]# chown -R root . [root@localhost mysql]# mkdir -p /usr/local/mysql/data[root@localhost mysql]# chown -R mysql data [root@localhost mysql]# bin/mysqld_safe --user=mysql &[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql [root@localhost mysql]# chkconfig --add mysql [root@localhost mysql]# chkconfig --level 2345 mysql on[root@localhost mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chkconfig mysqld on [root@localhost mysql]# service mysqld start Starting MySQL.. SUCCESS! [root@localhost mysql]# service mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL.. SUCCESS!二、添加环境变量:[root@localhost mysql]# vim /etc/profile export PATH=$PATH:/usr/local/mysql/bin# source /etc/profile补充:通过配置my.cnf mysql选项socket文件位置解决[root@localhost mysql]# service mysqld stopShutting down MySQL.. SUCCESS! [root@localhost mysql]# vim /etc/my.cnf在最后增加即可:[mysql]
no-auto-rehashsocket = /var/lib/mysql/mysql.sock[root@localhost mysql]# service mysqld startStarting MySQL.. SUCCESS! [root@localhost mysql]# mysql -uroot -p三、访问数据库,用安装时给的随机密码进行第一次登录:[root@localhost mysql]# mysql -uroot -p四、怎么修改 mysql 数据库的随机密码mysql> set password for 'root'@localhost = password ('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)[root@localhost support-files]# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 5Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 二进制 local