Linux 下安装mysql (tar.gz压缩包形式)

自己简单的安装一个mysql。目的:能够运行mysql即可。

缺点:没有任何配置上面的优化。

步骤:

1、在 oracle.com 上面下载社区版本的mysql

2、上传到Linux机器的目录

3、根据mysql官网给出的安装 "2.2 Installing MySQL on Unix/Linux Using Generic Binaries"的步骤进行安装。

如下:

写道
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

 并且这里假设用户使用的是root用户。

原文:

写道
Note
This procedure assumes that you have root (administrator) access to your
system. Alternatively, you can prefix each command using the sudo (Linux) or
pfexec (OpenSolaris) command.

运行命令:scripts/mysql_install_db --user=mysql 之后会给出很多的文字描述,这个很有用。具体如下:

写道
[root@cp01-kanpiaoxue-org mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2016-06-30 15:24:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-06-30 15:24:47 0 [Note] ./bin/mysqld (mysqld 5.6.31) starting as process 482 ...
2016-06-30 15:24:47 482 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-06-30 15:24:47 482 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-30 15:24:47 482 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-06-30 15:24:47 482 [Note] InnoDB: Memory barrier is not used
2016-06-30 15:24:47 482 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-30 15:24:47 482 [Note] InnoDB: Using Linux native AIO
2016-06-30 15:24:47 482 [Note] InnoDB: Using CPU crc32 instructions
2016-06-30 15:24:47 482 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-06-30 15:24:47 482 [Note] InnoDB: Completed initialization of buffer pool
2016-06-30 15:24:47 482 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-06-30 15:24:47 482 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-06-30 15:24:47 482 [Note] InnoDB: Database physically writes the file full: wait...
2016-06-30 15:24:47 482 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-06-30 15:24:47 482 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-06-30 15:24:47 482 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-06-30 15:24:47 482 [Warning] InnoDB: New log files created, LSN=45781
2016-06-30 15:24:47 482 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-06-30 15:24:47 482 [Note] InnoDB: Doublewrite buffer created
2016-06-30 15:24:47 482 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-30 15:24:47 482 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-06-30 15:24:47 482 [Note] InnoDB: Foreign key constraint system tables created
2016-06-30 15:24:47 482 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-06-30 15:24:47 482 [Note] InnoDB: Tablespace and datafile system tables created.
2016-06-30 15:24:47 482 [Note] InnoDB: Waiting for purge to start
2016-06-30 15:24:47 482 [Note] InnoDB: 5.6.31 started; log sequence number 0
2016-06-30 15:24:47 482 [Note] Binlog end
2016-06-30 15:24:47 482 [Note] InnoDB: FTS optimize thread exiting.
2016-06-30 15:24:47 482 [Note] InnoDB: Starting shutdown...
2016-06-30 15:24:49 482 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2016-06-30 15:24:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-06-30 15:24:49 0 [Note] ./bin/mysqld (mysqld 5.6.31) starting as process 539 ...
2016-06-30 15:24:49 539 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-06-30 15:24:49 539 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-30 15:24:49 539 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-06-30 15:24:49 539 [Note] InnoDB: Memory barrier is not used
2016-06-30 15:24:49 539 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-30 15:24:49 539 [Note] InnoDB: Using Linux native AIO
2016-06-30 15:24:49 539 [Note] InnoDB: Using CPU crc32 instructions
2016-06-30 15:24:49 539 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-06-30 15:24:49 539 [Note] InnoDB: Completed initialization of buffer pool
2016-06-30 15:24:49 539 [Note] InnoDB: Highest supported file format is Barracuda.
2016-06-30 15:24:49 539 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-30 15:24:49 539 [Note] InnoDB: Waiting for purge to start
2016-06-30 15:24:49 539 [Note] InnoDB: 5.6.31 started; log sequence number 1625977
2016-06-30 15:24:49 539 [Note] Binlog end
2016-06-30 15:24:49 539 [Note] InnoDB: FTS optimize thread exiting.
2016-06-30 15:24:49 539 [Note] InnoDB: Starting shutdown...
2016-06-30 15:24:51 539 [Note] InnoDB: Shutdown completed; log sequence number 1625987
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 cp01-kanpiaoxue-org.epc.com 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 at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

使用上面文字中提到的:./bin/mysqladmin -u root -h cp01-kanpiaoxue-org.epc.com password 'new-password' 修改密码。

使用 ./bin/mysql -u root -h cp01-kanpiaoxue-org.epc.com -p 可以进行登录mysql。

如果使用localhost登录,如: ./bin/mysql -u root -p 登录,会报错如下:

写道
Access denied for user 'root'@'localhost' (using password: YES)

 怎么解决呢?很简单。使用 ./bin/mysql -u root -h cp01-kanpiaoxue-org.epc.com -p 登录mysql,修改localhost以及密码即可。

mysql> use mysql;

mysql> update user set password=PASSWORD('这里改成你的密码') where User='root';
mysql> flush privileges;
mysql> quit

======== 小结

安装mysql的最好办法就是参考mysql官方文档的安装文档部分。没有比他更加权威的了。

猜你喜欢

转载自kanpiaoxue.iteye.com/blog/2308302