[root@localhost ~]# yum remove mysql
yum install gcc
yum install gcc-c++
yum install cmake
开始正式安装Mysql
添加mysql用户和用户组[root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql
下载mysql的源码包/usr/local/src下,解压
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar xzvf mysql-5.6.15.tar.gz
[root@localhost src]# cd mysql-5.6.15
cmake运行
[root@localhost mysql-5.6.15]# cmake .
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:82 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:126 (FIND_CURSES) cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt:250 (MYSQL_CHECK_READLINE) -- Configuring incomplete, errors occurred!缺少Curses包,解决办法:remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
[root@localhost mysql-5.6.15]# yum install ncurses-devel
重新cmake运行
[root@localhost mysql-5.6.15]# cmake . -DENABLE_DOWNLOADS=1
Warning: Bison executable not found in PATH
有一个警告,也解决了它,缺少Bison就安装一下
[root@localhost mysql-5.6.15]# yum install bison
再次运行,没有报错
[root@localhost mysql-5.6.15]# cmake . -DENABLE_DOWNLOADS=1
根据帮助信息选择自己需要设置的选项,当然也可以跳过这步,按默认设置
开始编译安装,时间有点稍长,可以泡杯咖啡转悠一下...
[root@localhost mysql-5.6.15]# make && make install
进入安装目录,将程序二进制的所有权改为root,数据目录的说有权改为mysql用户,更新授权表
[root@localhost mysql-5.6.15]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
安全启动mysql
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
关闭mysql
[root@localhost mysql]# ./bin/mysqladmin -u root shutdown -p
默认密码为空
方便调用,为mysql设置一个软链接
[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
有3种方法为root账户设置密码:
使用SET PASSWORD语句
[root@localhost ~]# mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd'); mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd')
使用mysqladmin命令行程序
[root@localhost ~]# mysqladmin -u root password "newpwd" [root@localhost ~]# mysqladmin -u root -h host_name password "newpwd"
使用UPDATE语句
[root@localhost ~]# mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') -> WHERE User = 'root'; mysql> FLUSH PRIVILEGES;
其他设置处理:
设置选项文件,将配置文件拷贝到/etc下
[root@localhost mysql]# cp my.cnf /etc/mysql.cnf
如果
设置开机自启动
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql [root@localhost mysql]# chmod +x /etc/init.d/mysql
现在可以通过服务来启动和关闭Mysql
[root@localhost ~]# service mysql start [root@localhost ~]# service mysql shutdown
基本上的安装就是这样了