从源代码安装mysql。
需要预装的软件包:
apt-get install cmake
apt-get install g++
apt-get install libncurses5-dev
apt-get install bison
编译:
编译选项参考http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html#option_cmake_build_config
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/usr2/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_DATADIR=/usr2/mysql/data \
-DENABLE_DEBUG_SYNC=OFF
make
make install
创建DB:
/usr2/mysql/scripts/mysql_install_db --user=root --basedir=/usr2/mysql --keep-my-cnf --datadir=/usr2/mysql/data --explicit_defaults_for_timestamp --collation-server=utf8_general_ci
配置:
my.cnf
[client]
explicit_defaults_for_timestamp=true
[mysqld]
user=root
character_set_server=utf8
collation-server=utf8_general_ci
explicit_defaults_for_timestamp=true
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
配置服务:
cp /usr2/src/mysql-5.6.20/support-files/mysql.server /etc/init.d/mysql
修改:
basedir=/usr2/mysql
datadir=/usr2/mysql/data
PATH设置:
# cat /etc/profile.d/mysql.sh
MYSQL_HOME=/usr2/mysql
PATH=${PATH}:${MYSQL_HOME}/bin
启动:
/etc/init.d/mysql start
登录:
mysql -u root -p
修改MySQL的root用户的密码以及打开远程连接:
mysql>use mysql;
mysql>desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
mysql>update user set Password = password('xxxxxx') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit
常用命令:
CREATE DATABASE `mediawiki` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
create user mwikiuser@localhost identified by 'mediawiki';
GRANT ALL PRIVILEGES ON mediawiki.* TO mwikiuser@% IDENTIFIED BY 'mediawiki';
DROP USER mwikiuser@localhost;
show grants for root@localhost;
阅读(933) | 评论(0) | 转发(0) |