mysql源码编译表_MYSQL 源码编译安装

1. 准备安装包:

[root@localhost ~]# ls

cmake-2.8.10.2.tar.gz mysql-5.5.30.tar.gz

2. 安装CMAKE:

tar -xzvf cmake-2.8.10.2.tar.gz

cd cmake-2.8.10.2

./configure

make

make install

3. 安装MYSQL

yum install ncurses-devel

groupadd mysql

useradd -r -g mysql mysql

mkdir -p /u01/mysql/data

mkdir -p /u01/mysql/logs/mysql

mkdir -p /u01/mysql/data/log

tar -xzvf mysql-5.5.30.tar.gz

cmake -DCMAKE_INSTALL_PREFIX=/u01/mysql -DMYSQL_DATADIR=/u01/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

make

make install

cd /u01

chown -R root:mysql mysql

chown -R mysql:mysql mysql

cd mysql

cp support-files/my-medium.cnf /etc/my.cnf

4. 初始化DB:

[root@localhost mysql]# scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql

Installing MySQL system tables...

140425 12:08:57 mysqld_safe mysqld from pid file /u01/mysql/data/localhost.localdomain.pid ended

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:

./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h 127.0.0.1 password 'new-password'

Alternatively you can run:

./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 . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

[1]+ Done ./mysqld_safe (wd: /u01/mysql/bin)

5. 修改ROOT密码:

[root@localhost ~]# mysqld_safe --defaults-file=/etc/my.cnf &

140426 12:12:43 mysqld_safe Logging to '/u01/mysql/logs/mysql/error3306.log'.

140426 12:12:44 mysqld_safe Starting mysqld daemon with databases from /u01/mysql/data

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.30-log 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.

root@localhost : (none) 12:12:29> use mysql;

Database changed

root@localhost : mysql 12:12:45> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";

Query OK, 0 rows affected (0.00 sec)

root@localhost : mysql 12:12:47> update user set password = password('123456') where user='root';

Query OK, 4 rows affected (0.01 sec)

Rows matched: 5 Changed: 4 Warnings: 0

root@localhost : mysql 12:12:55> commit;

Query OK, 0 rows affected (0.00 sec)

root@localhost : mysql 12:13:01> flush privileges;

Query OK, 0 rows affected (0.00 sec)

第一次登录是不需要密码的。

尝试用新密码登录:

[root@localhost ~]# mysql -uroot -p -S /tmp/mysql3306.sock

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.30-log 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.

root@localhost : (none) 12:13:41>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值