Existing environment:
1) Download MySQL Community Server 5.6.17 compact version (mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz)
2) installation directory:/opt/library/mysql-5.6.17-linux-glibc2.5-x86_64
3) Soft link for/opt/library/mysql, pointing to mysql-5.6.17-linux-glibc2.5-x86_64 in the same directory
1. Create MySQL-specific users and groups
?
12 |
$ sudo groupadd mysql $ sudo useradd -r -g mysql mysql |
2. Modify the MySQL folder and the owner of the soft link
?
12 |
$ sudo chown -R mysql:mysql mysql-5.6.17-linux-glibc2.5-x86_64/ $ sudo chown -R mysql:mysql mysql |
3. Initialize the authorization table with mysql_install_db. This is only required when MySQL is first installed, and if it is an existing installation, you can skip this step or overwrite the previous authorization information.
?
1 |
$ sudo scripts /mysql_install_db --user=mysql |
4. mysql_install_db execution error was found. Look at the error prompt, originally because of the lack of shared library libaio1.
?
12 |
[email protected]: /opt/library/mysql $ sudo scripts /mysql_install_db --user=mysql installing MySQL system tables .... /bin/mysqld : Error while loading shared libraries:libaio.so.1:cannot open shared object file : No such file or directory |
5. Installing Libaio1
?
1 |
$ sudo apt-get install libaio1 |
6. Re-execute the third step, here are a few lines of key log
?
123456789101112131415161718192021222324252627282930313233343536373839404142 |
Installing MySQL system tables...2014-05-15 14:43:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
for more details).
.
.
创建第一张数据表、表大小、buffer、fk、log文件
.
Filling help tables...2014-05-15 14:43:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
for more details).
.
.
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 xuyuzhu-OptiPlex-990 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
.
.
|
Summary below:
1) support-files/mysql.server for starting MySQL
2) Use mysqladmin or mysql_secure_installation command to change password
3) You can use the CD. ;./bin/mysqld_safe & "Configuring the MySQL Daemon
7. Add MySQL startup script soft link
?
12 |
$ cd /etc/init .d/ $ sudo ln -s /opt/library/mysql/support-files/mysql .server |
8. Start the MySQL service
?
12345 |
[email protected]:
/etc/init
.d$ .
/mysql
.server start
/etc/init
.d
/mysql
.server: 1:
/etc/init
.d
/mysql
.server: my_print_defaults: not found
/etc/init
.d
/mysql
.server: 276:
cd
: can‘t
cd to
/usr/local/mysql
Starting MySQL
* Couldn‘t
find MySQL server (
/usr/local/mysql/bin/mysqld_safe
)
|
9. Error. Because mysql.server reads the MySQL directory is/user/local/mysql, so in/user/local/, create a, MySQL soft link to/opt/library/mysql. Take the 8th step again.
?
12345 |
$ ln -s Code class= "Bash plain" >/opt/library/mysql /usr/local/mysql $ sudo chown mysql:mysql /usr/local/mysql $ sudo /mysql .server start # above must be started with sudo permissions, otherwise it will be reported. * The server quit without updating PID file (/usr/local/mysql/data/xu yuzhu-optiplex-990.pid). starting MySQL |
PS Inspection Process
?
1234 |
[email protected]:
/etc/init
.d$
ps -aux |
grep mysql
root 373 0.0 0.0 4444 744 pts
/13
S 15:16 0:00
/bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=
/usr/local/mysql/data --pid-
file
=
/usr/local/mysql/data/xuyuzhu-OptiPlex-990
.pid
mysql 484 2.4 11.4 976004 448164 pts
/13
Sl 15:16 0:00
/usr/local/mysql/bin/mysqld --basedir=
/usr/local/mysql --datadir=
/usr/local/mysql/data --plugin-
dir
=
/usr/local/mysql/lib/plugin --user=mysql --log-error=
/usr/local/mysql/data/xuyuzhu-OptiPlex-990
.err --pid-
file
=
/usr/local/mysql/data/xuyuzhu-OptiPlex-990
.pid
xuyuzhu 511 0.0 0.0 15960 916 pts
/13
S+ 15:16 0:00
grep --color=auto mysql
|
Mysqladmin Check if MySQL can be used
?
123456789101112131415 |
$ mysqladmin version
mysqladmin Ver 8.42 Distrib 5.6.17,
for linux-glibc2.5 on x86_64
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.
Server version5.6.17
Protocol version10
ConnectionLocalhost via UNIX socket
UNIX socket
/tmp/mysql
.sock
Uptime:4 min 48 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.006
|
12. Add boot up the MySQL service daemon
?
123456789 |
[email protected]:
/etc/init
.d$
sudo update-rc.d mysql.server defaults
Adding system startup
for /etc/init
.d
/mysql
.server ...
/etc/rc0
.d
/K20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc1
.d
/K20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc6
.d
/K20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc2
.d
/S20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc3
.d
/S20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc4
.d
/S20mysql
.server -> ..
/init
.d
/mysql
.server
/etc/rc5
.d
/S20mysql
.server -> ..
/init
.d
/mysql
.server
|
. That's all.
Reference http://www.cnblogs.com/eastson/archive/2012/06/09/2543489.html