-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_DATADIR=/data/mysql/ \-DMYSQL_USER=mysql \-DMYSQL_TCP_PORT=3306
所以上面的编译条件省掉了如下两行-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \但INNODB一定要声明式安装,所以多了这一行-DWITH_INNOBASE_STORAGE_ENGINE=1 \
[root@localhost ~]# useradd mysql -g mysql -s /sbin/nologin #
添加mysql用户
[root@localhost ~]# chown mysql.mysql -R . #将mysql目录赋予mysql用户的执行权限
[root@localhost ~]# chown mysql.mysql -R /data/mysql
[root@localhost ~]# chmod 755 scripts/mysql_install_db #赋予mysql_install_db执行权限
[root@localhost ~]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
[root@localhost ~]# chmod 755 /etc/init.d/mysqld
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos.huoba password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[root@localhost ~]# /usr/local/mysql//mysql -u root -p #敲入该命令后,屏幕会提示输入密码,输入上一步设置的yourpassword
删除root密码为空的记录
mysql> use mysql;
mysql> delete from user where password='';
mysql> flush privileges;
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel gmp-devel ncurses ncurses-devel unixODBC-devel openldap openldap-devel -y
yum install cmake make -y
yum install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* -y
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/home/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
make && make install
cd /usr/local/mysql
chown mysql.mysql -R .
chown mysql.mysql -R /home/data/mysql
cp support-files/my-default.cnf /etc/my.cnf
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --list|grep mysqld
chkconfig mysqld on