编译安装mysql
1 查找系统是否安装了myql rpm -q mysql mysql-server1.1如果安装了。就删除 sudo yum -y remove mysql mysql-server sudo rm -rf /etc/my.cnf 2 安装依赖 sudo yum install ncurses-devel -y sudo yum install libaio-devel -y sudo yum install bison -y sudo yum install openssl-devel -y sudo yum install gcc -y sudo yum install gcc-c++ sudo yum install cmake -y sudo yum install make -yubutu可能需要安装以下apt-get install bisonapt-get install library*apt-get install libncurses5-devapt-get install g++apt-get install kdelibs5-dev
3安装Mysql1 创建mysql用户及用户组 groupadd mysql useradd -M -g mysql -s /sbin/nologin mysql
说明
-M 强制不创建用户目录 -g指定用户组,-s /sbin/nologin 设置mysql用户不能以用户身份登录mysql是用户名2 创建mysql的安装目录及数据库存放目录
mkdir -p /usr/local/mysql mkdir -p /usr/local/mysql/data 3 安装cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 安装位置-DSYSCONFDIR=/etc \ 配置文件目录-DMYSQL_DATADIR=/usr/local/mysql/data \ 数据库位置-DMYSQL_TCP_PORT=3306 \ MySQL监听端口-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ 套接字文件-DDEFAULT_CHARSET=utf8 \ 默认字符-DDEFAULT_COLLATION=utf8_general_ci \ 字符集-DENABLED_LOCAL_INFILE=1 \ 允许从本地导入数据-DWITH_READLINE=1 \ //快捷键功能-DWITH_SSL=system \-DWITH_EXTRA_CHARSETS=all \-DWITH_EMBEDDED_SERVER=1 \ //编译成embedded MySQL library(libmysqld.a)-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 安装innodb存储引擎-DWITH_MYISAM_STORAGE_ENGINE=1 \ 安装myisam存储引擎 sudo cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=system -DMYSQL_DATADIR=/usr/local/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 4执行,sudo make 5 执行 sudo make install6 sudo chown -R mysql:mysql mysql/
7 初始化Mysql
sudo ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data8
[c4t@localhost support-files]$ sudo cp my-huge.cnf /etc/my.cnf[c4t@localhost support-files]$ sudo cp mysql.server /etc/init.d/mysqld[c4t@localhost support-files]$ sudo chmod 755 /etc/init.d/mysqld [c4t@localhost support-files]$ sudo chkconfig --add mysqld //添加到各个启动级别,可以不添加设置开机自动运行
sudo chkconfig mysqld on启动mysqlsudo service mysqld startsudo service mysql stop启动mysql:方式一:sudo /etc/init.d/mysql start 方式二:sudo start mysql方式三:sudo service mysql start停止mysql:方式一:sudo /etc/init.d/mysql stop 方式二:sudo stop mysql方式san:sudo service mysql stop重启mysql:方式一:sudo/etc/init.d/mysql restart方式二:sudo restart mysql方式三:sudo service mysql restart