[iyunv@httpd mysql-5.5.37]# cd /usr/local/mysql-5.5.37/
[iyunv@httpd mysql-5.5.37]# scripts/mysql_install_db --datadir=/data/mysql/data/ --user=mysql --basedir=/usr/local/mysql-5.5.37/
Installing MySQL system tables...
OK
Filling help tables...
OK #到这里显示的有2个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:
Alternatively you can run:
/usr/local/mysql-5.5.37//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 /usr/local/mysql-5.5.37/ ; /usr/local/mysql-5.5.37//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql-5.5.37//mysql-test ; perl mysql-test-run.pl
[iyunv@httpd ~]# which mysql
/usr/bin/which: no mysql in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
#配置软连接
[iyunv@httpd ~]# ln -s /usr/local/mysql-5.5.37/ /usr/local/mysql
[iyunv@httpd ~]# ln -s /usr/local/mysql-5.5.37/bin/* /usr/sbin/
[iyunv@httpd ~]# which mysql
/usr/sbin/mysql
连接到数据库
[iyunv@httpd ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.37-log Source distribution
Copyright (c) 2000, 2014, 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账号的密码,设置密码是ly36843
mysql> update user set password=password('lyao36843') where host="localhost" and user="root";
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update user set password=password('lyao36843') where host="127.0.0.1" and user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
#退出数据库重新连接
[iyunv@httpd ~]# mysql -u root -p -h 127.0.0.1
Enter password: #输入之前设置的mysql数据库密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.37-log Source distribution
Copyright (c) 2000, 2014, 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.