源码编译Mysql
环境:CentOS 6.5
[root@localhost software]# yum -y install gcc gcc-c++ [root@localhost software]# tar -zxvf cmake-2.8.5.tar.gz [root@localhost software]# cd cmake-2.8.5 [root@localhost cmake-2.8.5]# ./configure --prefix=/usr/local/cmake ··· CMake has bootstrapped. Now run gmake. [root@localhost cmake-2.8.5]# gmake [root@localhost cmake-2.8.5]# make install [root@localhost software]# yum -y install bison ncurses-devel [root@localhost software]# useradd mysql -s /sbin/nologin [root@localhost software]# tar -zxvf mysql-5.5.25.tar.gz [root@localhost software]# cd mysql-5.5.25 [root@localhost mysql-5.5.25]# mkdir -p /usr/local/mysql/data [root@localhost mysql-5.5.25]# mkdir -p /usr/local/mysql/etc [root@localhost mysql-5.5.25]# mkdir -p /usr/local/mysql/log [root@localhost mysql-5.5.25]# /usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data [root@localhost mysql-5.5.25]# make &&make install [root@localhost mysql-5.5.25]# make clean &&rm -rf CMakeCache.txt /etc/my.cnf [root@localhost mysql-5.5.25]# chown mysql:mysql /usr/local/mysql/ -R [root@localhost mysql-5.5.25]# cd /usr/local/mysql/ [root@localhost mysql]# cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf [root@localhost mysql-5.5.25]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql-5.5.25]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/usr/local/mysql/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql //初始化mysql数据库 [root@localhost ~]# chmod +x /etc/init.d/mysqld [root@localhost ~]# head -n 47 /etc/init.d/mysqld |tail -n 2 basedir="/usr/local/mysql" datadir="/usr/local/mysql/data" [root@localhost ~]# /etc/init.d/mysqld start Starting MySQL... SUCCESS! [root@localhost ~]#
[root@localhost ~]# chkconfig mysqld on [root@localhost ~]# netstat -tunlp|grep mysqld tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1451/mysqld [root@localhost ~]# [root@localhost ~]# /usr/local/mysql/bin/mysqladmin -u root password redhat //刚装完数据库用这个命令给root用户设置密码
[root@localhost ~]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
修改root用户密码:
在外部修改root用户密码:
[root@localhost ~]# /usr/local/mysql/bin/mysqladmin -u root -p password "redhat" Enter password: [输入原来的密码] [root@localhost ~]#
在MYSQL数据库里面修改root用户密码:
[root@localhost ~]# /usr/local/mysql/bin/mysql -u root -p
Enter password:[输入原来的密码]
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> use mysql; Database changed mysql> update user set password=password(‘redhat123‘) where user=‘root‘; Query OK, 4 rows affected (0.01 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> quit Bye [root@localhost ~]# ln -s /usr/local/mysql/bin/* /bin/
本文出自 “鹏城-酱油瓶” 博客,谢绝转载!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。