Centos源码安装mysql

  rz -y
  yum install gcc-c++
  [root@localhost cmake-2.8.8]# ./configure
[root@localhost cmake-2.8.8]#gmake
[root@localhost cmake-2.8.8]# gamke install
[root@localhost cmake-2.8.8]# echo $0
bash
[root@localhost cmake-2.8.8]# cd ..
[root@localhost soft]# yum install ncurses-devel -y
阿里云源
[localhost soft]# tar -xf mysql-5.5.32.tar.gz
st soft]# cd mysql-5.5.32
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd mysql -s/sbin/nologin -M -g mysql


   cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 -DMYSQL_DATADIR=/application/mysql-5.5.32/data -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1   -DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3306

[root@localhost mysql-5.5.32]# make && make install
ln -s /application/mysql-5.5.32/ /application/mysql
[root@localhost mysql-5.5.32]# cd ..
[root@localhost soft]# ls
cmake-2.8.8         mysql-5.5.32
cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz

oot@localhost soft]# cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@localhost soft]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
[root@localhost soft]# echo $PATH
/application/mysql/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin
[root@localhost soft]# ll /application/mysql/data/
total 4
drwxr-xr-x. 2 root root 4096 Dec 25 03:19 test
[root@localhost soft]# chown -R mysql.mysql /application/mysql/data
[root@localhost soft]# chmod -R 1777 /tmp/
[root@localhost soft]# cd /application/mysql/scripts
[root@localhost scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

[root@localhost mysql]# cd ~/soft
[root@localhost mysql]# cd ~/soft
[root@localhost soft]# ls
cmake-2.8.8  cmake-2.8.8.tar.gz  mysql-5.5.32  mysql-5.5.32.tar.gz
[root@localhost soft]# cd mysql-5.5.32
[root@localhost mysql-5.5.32]# /bin/cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.32]# chmod +x /etc/init.d/mysqld
[root@localhost mysql-5.5.32]# /etc/init.d/mysqld start
Starting MySQL.... SUCCESS!
[root@localhost mysql-5.5.32]#
[root@localhost mysql-5.5.32]# netstat -lntup|grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      46593/mysqld        
[root@localhost mysql-5.5.32]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, 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.
#额外授权管理员 grant all privileges on *.* to system@'localhost' identified by 'admin' with grant option
mysql>
mysql> select user,host from mysql.user;
+------+-----------------------+
| user | host                  |
+------+-----------------------+
| root | 127.0.0.1             |
| root | ::1                   |
|      | localhost             |
| root | localhost             |
|      | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+
6 rows in set (0.00 sec)
mysql> select user,host from mysql.user;
+------+-----------------------+
| user | host                  |
+------+-----------------------+
| root | 127.0.0.1             |
| root | ::1                   |
|      | localhost             |
| root | localhost             |
|      | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+
6 rows in set (0.00 sec)

mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)

mysql> select user,host from mysql.user;
+------+-----------------------+
| user | host                  |
+------+-----------------------+
| root | 127.0.0.1             |
| root | ::1                   |
| root | localhost             |
| root | localhost.localdomain |
+------+-----------------------+
4 rows in set (0.00 sec)

mysql> delete from mysql.user where host='::1';
Query OK, 1 row affected (0.00 sec)

mysql> select user,host from mysql.user;
+------+-----------------------+
| user | host                  |
+------+-----------------------+
| root | 127.0.0.1             |
| root | localhost             |
| root | localhost.localdomain |
+------+-----------------------+
3 rows in set (0.00 sec)

mysql> delete from mysql.user where host='localhost.localdomain';
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.05 sec)

mysql> drop test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test' at line 1
mysql> drop table test;
ERROR 1046 (3D000): No database selected
mysql> drop database test;
Query OK, 0 rows affected (0.01 sec)

mysql>  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql>
mysql> quit;
Bye
/application/mysql/bin/mysqladmin -u root password 'admin' #'new-password'
[root@localhost mysql-5.5.32]# vi /etc/sysconfig/i18n
#LANG="en_US.UTF-8"
#LANG="en_US.UTF-8"
LANG="zh_CN.UTF-8"
[root@localhost mysql-5.5.32]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, 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@localhost mysql-5.5.32]# chkconfig mysqld on
[root@localhost mysql-5.5.32]# chkconfig --list mysqld
mysqld             0:off    1:off    2:on    3:on    4:on    5:on    6:off




你可能感兴趣的:(Centos源码安装mysql)