MySql5.5.37编译安装详解
今天为大家介绍下mysql5.5.37的编译安装方式,在工作中编译安装也是我们常用的一种方式。希望通过这篇文章的介绍,能够给大家提供一个安装思路!
一、创建mysql的安装目录和用户
mkdir -p /usr/local/mysql #安装mysql mkdir -p /usr/local/mysql/data #存放数据库 groupadd mysql useradd -r -g mysql mysql
二、yum安装依赖库
yum install gcc-c++ ncurses-devel –y
#安装错误信息: CMake Error atcmake/readlineNaNake:83 (MESSAGE): Curses library notfound. Please install appropriatepackage, #解决方法 yum install ncurses-devel rm CMakeCache.txt
三、编译安装cmake
tar -zxv -f cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./configure make && make install
四、编译安装mysql5.5.37
tar -zxv -f mysql-5.5.37.tar.gz #解压 cd mysql-5.5.37 #编译参数 [root@localhost mysql-5.5.37]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 #执行make命令 make make install
五、检查是否安装成功
cd /usr/local/mysql/ [root@localhost mysql]#ls bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share sql-bench support-files #有bin等以上文件的话,恭喜你已经成功安装了mysql。
六、配置mysql5.5.37详细步骤
#把当前目录中所有文件的所有者设为root,所属组为mysql chown -R root:mysql . chown -R mysql:mysql data (可选) #将mysql的启动服务添加到系统服务中 [root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf cp:是否覆盖"/etc/my.cnf"? y
#mysql启动出错解决方法 1、问题 [root@localhost mysql]# /etc/rc.d/init.d/mysql statusMySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED][root@localhost mysql]# /etc/rc.d/init.d/mysql startStarting MySQL...The server quit without updating PID file(/usr/local/mysql/data/localhost.localdomain.pid). [FAILED] 2、原因 没有初始化权限表 3、解决办法 cd /usr/local/mysql(进入mysql安装目录)chown -R mysql.mysql . #重新初始化数据库 [root@B2C-test-server mysql]# ./scripts/mysql_install_db--user=mysql [root@B2C-test-server mysql]# /etc/init.d/mysql start Starting MySQL.. SUCCESS!
#直接输入mysql启动数据库出错: [root@localhost mysql]# mysql -bash: mysql: command not found #解决方法 [root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql/usr/bin/
#修改MySQL的root用户的密码以及打开远程连接 [root@B2C-test-server mysql]# mysql -u root mysql mysql> use mysql; mysql> desc user; mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; #为root添加远程连接的能力 mysql> update user set Password = password(‘123456‘) where User=‘root‘; #设置root用户密码 mysql> select Host,User,Password from user where User=‘root‘; mysql> flush privileges; mysql> exit #重新登录 [root@B2C-test-server mysql]# mysql -u root -p Enter password:123456 #若还不能进行远程连接,关闭防火墙 [root@B2C-test-server mysql]# /etc/rc.d/init.d/iptables stop
七、设置mysql密码
#方法一:在mysql系统外,使用mysqladmin [root@B2C-test-server mysql]# mysqladmin -u rootflush-privileges password ‘root‘
#方法一:通过登录mysql系统 [root@B2C-test-server mysql]# mysql -u root -p Enter password: mysql> use mysql; Database changed mysql> update user set password=password("root")where user=‘root‘; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges; mysql> exit;
八、Mysql root密码忘记解决方法
#方法一: # /etc/init.d/mysqld stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking& # mysql -uroot mysql mysql> update user setPassword=Password(‘newpassword‘) where User=‘root‘; mysql> flush privileges; mysql> quit # /etc/init.d/mysql restart # mysql -uroot -penter password:
#方法二: #修改MySQL的登录设置: #在[mysqld]的段中加上一句:skip-grant-tables 如下: [root@B2C-test-server mysql]# vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql skip-grant-tables #重启mysql /etc/init.d/mysqld restartStoppingmysqld: [ OK ]Startingmysqld: [ OK ] #无密码登录: # mysql mysql> use mysql;update user setPassword=Password(‘root‘) where User=‘root‘; mysql> flush privileges; #退出,修改/etc/my.conf,删除skip-grant-tables,重启mysql。搞定
OK! mysql的编译安装今天就先介绍到这里吧!
本文出自 “小虾” 博客,请务必保留此出处http://liangey.blog.51cto.com/9097868/1626945
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。