2
Install MySQL
Groupadd MySQL #添加mysql组
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Chown-r Mysql:mysql/data/mysql #设置MySQL数据库目录权限
Mkdir-p/usr/local/mysql #创建MySQL安装目录
Cd/usr/local/src
Tar zxvf mysql-5.5.25.tar.gz #解压
CD mysql-5.5.25
CMake. -dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/data/mysql \
-DSYSCONFDIR=/ETC \
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_readline=1 \
-dwith_ssl=system \
-dwith_zlib=system \
-dwith_libwrap=0 \
-dmysql_unix_addr=/tmp/mysql.sock \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci #配置
Make #编译
Make install #安装
Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, you can overwrite it directly)
VI/ETC/MY.CNF #编辑配置文件, add the following line in the [mysqld] section
DataDir =/data/mysql #添加MySQL数据库路径
: wq! #保存退出
./scripts/mysql_install_db--user=mysql #生成mysql系统数据库
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #设置开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
Basedir =/usr/local/mysql #MySQL程序安装路径
DataDir =/data/mysql #MySQl数据库存放目录
Service mysqld Start #启动
Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
: wq! #保存退出
The following two lines link the MYSLQ library file to the default location of the system, and you can compile software like PHP without specifying the MySQL library file address.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Shutdown-r now #需要重启系统, wait for the system to restart after the operation continues under the terminal command line
Mysql_secure_installation #设置Mysql密码
Press Y to enter as prompted (the default password is blank)
Then enter the password 2 times
Continue to press Y to enter until Setup is complete
or modify the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456" #修改密码
Service mysqld Restart #重启
To this, MySQL installation is complete!