Mysql5.5以后使用cmake安装
安装时需要cmake和ncurses-devel。
1.1.1. 安装依赖库
安装ncurses-devel ,cmake库
yum install ncurses-devel
yum install cmake
安装mysql
程序存放目录,数据存放目录,新建mysql用户和组
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/data
groupadd mysql
useradd -r -g mysql mysql
cmake配置检测
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 install
配置mysql
将mysql的配置程序覆盖默认的配置文件
cp support-files/my-medium.cnf /etc/my.cnf
创建数据库
cd /usr/local/mysql
script/mysql_install_db --user=mysql
在修改PATH=$PATH:$HOME/bin为:
vi /root/.bash_profile
#PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
source /root/.bash_profile
将mysql的启动服务添加到系统服务中
cp support-files/mysql.server /etc/init.d/mysql
改变mysql安装目录的权限,因为mysql用mysql用户启动
chown -R mysql.mysql/usr/local/mysql/
启动mysql服务
/etc/init.d/mysql start
登录mysql,刚安装没有密码
mysql -u root mysql
设置root用户密码
update user set Password = password('123456') whereUser='root';
配置远程登录
GRANT ALL PRIVILEGES ON *.* TO root@"%"IDENTIFIED BY "123456";
flush privileges;
有时出以下出错,是因为没有修改mysql安装目录的权限,改为msyql用户即可
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).