编译安装mysql

group add mysql
useradd mysql -g mysql -s /bin/bash

进入mysql源码目录,执行以下代码
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=mysql \
-DSYSCONFDIR=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld.sock \
-DWITH_SSL=yes \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DINSTALL_PLUGINDIR=/usr/local/mysql/plugin \
-DWITH_ZLIB=yes \

make
make install

cd /usr/local
chown -R mysql.mysql mysql

su mysql

cd mysql
cp support-files/my-large.cnf my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
cd /etc/init.d
chmod +x mysqld
chkconfig --add mysqld
chkconfig mysqld on

初始化数据库表
cd /usr/local/mysql

./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

启动mysql
service mysqld start

初始化用户名密码,删除匿名用户
./bin/mysqladmin -u root password "root"
./bin/mysql -uroot -proot

执行sql语句
mysql> delete from mysql.user where user="";

至此大功告成

你可能感兴趣的:(mysql)