groupadd MySQL #添加mysql组 useradd-G MySQL mysql-s/bin/false#创建用户mysql并加入到mysql组, MySQL users are not allowed to log in directly to the systemmkdir-p/data/MySQL #创建MySQL数据库存放目Chown-R mysql:mysql/data/MySQL #设置MySQL数据库目录权限mkdir-p/usr/local/MySQL #创建MySQL安装目录 cd/optTarZXVF mysql-5.5. *.Tar. GZCD MySQL-5.5. *CMake-dcmake_install_prefix=/usr/local/MySQL-dmysql_unix_addr=/tmp/Mysql.sock-ddefault_charset=UTF8-ddefault_collation=utf8_general_ci \-dwith_extra_charsets=All \-dwith_myisam_storage_engine=1 -dwith_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_readline=1 -denabled_local_infile=1 -dmysql_datadir=/data/MySQL-dmysql_user=MySQL-dmysql_tcp_port=3306 -dsysconfdir=/etc-dinstall_sharedir=share
Make&& Make InstallTo start configuring MySQL after the installation is complete:CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: if/etc directory under the default has a my.cnf, directly overwrite can be)VI/etc/my.cnf #编辑配置文件, add the following line in the [mysqld] section DataDir=/data/MySQL #添加MySQL数据库路径: Wq!#保存退出 CD/usr/local/Mysql
When I started MySQL I want to put the database data file under another directory, the start command modified to: NOTE: the instance directory, the installation of the error occurred here.
Shell>/usr/local/mysql/bin/mysqld_safe--user=mysql--log-error=/u01/mysql/mysql_error/error--datadir=/data/ mysql/
There's a problem at this point,
Because the permissions table created by default at the time of the initialization Database permissions table is under the default directory/usr/local/mysql/var, this causes the above error to not find the permission table: Can ' t
Open and Lock Privilege tables:table ' mysql.host ' doesn ' t exist
./scripts/mysql_install_db--user=MySQL--datadir=/data/mysql #生成mysql系统数据库 Note: Because the database needs to be saved in another directory when you run the Initialize permission table, use the Add parameter--datadir
CP./support-files/mysql.server/etc/rc.d/init.d/MySQL #把Mysql加入系统启动
chmod 755/etc/init.d/MySQL #增加执行权限
Chkconfig MySQL on #加入开机启动VI/etc/rc.d/init.d/MySQL #编辑 basedir=/usr/local/MySQL #MySQL程序安装路径 datadir=/data/MySQL #MySQl数据库存放目录 service mysqld start #启动VI/etc/Profile #把mysql服务加入系统环境变量: Add the following line at the end of the export PATH= $PATH:/usr/local/mysql/Bin:wq! #保存退出
Ln -s/usr/local/mysql/include/mysql/usr/include/mysql reboot #需要重启系统, wait for the system to restart and continue to operate under the terminal command line Mysql_ Secure_installation #设置Mysql密码 Follow the prompts press Y to enter and then type 2 password to continue to press Y to enter, until the setup is complete or directly modify the password "123456"