Java Learning Note--linux installation configuration MySQL

Source: Internet
Author: User
Tags mkdir uuid file permissions

situations, Vista

--Tour Shanxi village

System: Ubuntu 16.04LTS

1\ official website Download mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

2\ set up a workgroup:
$su
#groupadd MySQL
#useradd-R-G MySQL MySQL

3\ Creating a Directory
#mkdir/usr/local/mysql
#mkdir/usr/local/mysql/data

4\ unzip the mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz and copy to/usr/local/mysql
#tar-ZXVF mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
#cp-R/home/jieyamulu/mysql-5.7.18-linux-glibc2.5-x86_64/*/usr/local/mysql

5\ Modify the MySQL user's permissions to the following files in MySQL and its subfolders, and use LL to view the permissions after modification
[Email protected]***:/usr/local# chown-r mysql:mysql MySQL
[Email protected]***:/usr/local# ll
Total Dosage 44
Drwxr-xr-x root root 4096 May 19 07:39.
Drwxr-xr-x root root 4096 February 16 04:30. /
Drwxr-xr-x 2 root root 4096 February 04:19 bin/
Drwxr-xr-x 2 root root 4096 February 04:19 etc/
Drwxr-xr-x 2 root root 4096 February 04:19 games/
Drwxr-xr-x 2 root root 4096 February 04:19 include/
Drwxr-xr-x 4 root root 4096 February 04:23 lib/
lrwxrwxrwx 1 root root 9 March 14:11 man--share/man/
drwxr-xr-x mysql mysql 4096 May 07:48 mysql/
Drwxr-xr-x 2 root root 4096 February 04:19 sbin/
Drwxr-xr-x 8 root root 4096 February 04:34 share/
Drwxr-xr-x 2 root root 4096 February 04:19 src/
[Email protected]***:/usr/local# cd mysql/
[Email protected]***:/usr/local/mysql# ll
Total Dosage 64
drwxr-xr-x MySQL mysql 4096 May 19 07:48.
Drwxr-xr-x root root 4096 May 19 07:39. /
Drwxr-xr-x 2 mysql mysql 4096 May 07:48 bin/
-rw-r--r--1 mysql mysql 17987 May 07:48 COPYING
Drwxr-xr-x 2 mysql mysql 4096 May 07:41 data/
Drwxr-xr-x 2 mysql mysql 4096 May 07:48 docs/
Drwxr-xr-x 3 mysql mysql 4096 May 07:48 include/
Drwxr-xr-x 5 mysql mysql 4096 May 07:48 lib/
Drwxr-xr-x 4 mysql mysql 4096 May 07:48 man/
-rw-r--r--1 mysql mysql 2478 May 07:48 README
drwxr-xr-x mysql mysql 4096 May 07:48 share/
Drwxr-xr-x 2 mysql mysql 4096 May 07:48 support-files/

6\ modifying (or creating a new)/etc/my.cnf configuration file
[Email protected]***:/usr/local/mysql# vim/etc/my.cnf
[Mysqld] basedir=/usr/local/mysql/
Datadir=/usr/local/mysql/data
: Wq

7\ the most critical initialization
# cd/usr/local/mysql/
[Email protected]***:/usr/local/mysql#./bin/mysqld--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/ Mysql/data--initialize

2017-05-19t00:15:46.529420z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-19t00:15:47.066125z 0 [Warning] innodb:new log files created, lsn=45790
2017-05-19t00:15:47.213711z 0 [Warning] innodb:creating FOREIGN KEY constraint system tables.
2017-05-19t00:15:47.286951z 0 [Warning] No existing UUID have been found, so we assume that's the first time that thi s server has been started. Generating a new uuid:4e958344-3c28-11e7-8334-c8d3ffd2db82.
2017-05-19t00:15:47.292857z 0 [Warning] Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened.
2017-05-19t00:15:47.294758z 1 [Note] A temporary password is generated for [email protected]: YJAOTQK*2EW4
The initial password to remember
There may be many problems here, such as:
Installing MySQL system Tables..../bin/mysqld:error while loading shared libraries:libaio.so.1:cannot open shared objec T file:no such file or directory
Missing dependency Packages
Workaround: sudo apt-get install Libaio-dev
It is also possible that the previous step did not cause the operation of the data file permissions are not enough, and so on. Follow the steps, what is missing (hint), it should be initialized successfully here, the few warning, it is worth noting that Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened. There is time to find out what is going on, and this omission has no effect.

8\ do not rush to start, and now can not start. Execute the code and change the file to root in MySQL except the Data folder
[Email protected]***:/usr/local/mysql# chown-r root.
[Email protected]***:/usr/local/mysql# chown-r MySQL Data

9\ start
[Email protected]***:/usr/local/mysql# bin/mysqld_safe--user=mysql &
Hit Enter
[Email protected]***:/usr/local/mysql#/usr/local/mysql/bin/mysql-uroot-p

Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server version:5.7.18

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> show databases;
ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.
Mysql>

10\ Reset Password
mysql> SET PASSWORD = PASSWORD (' newpasswd ');
Query OK, 0 rows affected, 1 Warning (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| SYS |
+--------------------+
4 rows in Set (0.00 sec)
Mysql> quit
Bye

11\ Set Boot start
[Email protected]***:/usr/local/mysql# cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
[Email protected]***:/usr/local/mysql# chmod 755/etc/init.d/mysqld

12\ Installing Mysql-server and Mysql-client
[Email protected]***:~# apt-get Install Mysql-server
[Email protected]***:~# apt-get Install mysql-client
[Email protected]***:~# apt-get Install Libmysqlclient-dev


E:sub-process/usr/bin/dpkg returned an error code (1)
Workaround:
1.$ sudo mv/var/lib/dpkg/info/var/lib/dpkg/info_old//renaming the Info folder now
2.$ sudo mkdir/var/lib/dpkg/info//re-create a new info folder
3.$ sudo apt-get update,

$ apt-get-f Install//repair dependency tree
4.$ sudo mv/var/lib/dpkg/info/*/var/lib/dpkg/info_old//After performing the previous action, some files are generated under the new Info folder and are now moved to the Info_old folder
5.$ sudo rm-rf/var/lib/dpkg/info//delete your new info folder
6.$ sudo mv/var/lib/dpkg/info_old/var/lib/dpkg/info//Change the previous Info folder back to the name

Finally, if the Ubuntu system may not be able to insert Chinese characters into the table, you cannot query the kanji from the table ...

Workaround:
Shutting down the database service
Service MySQL Stop
~$ sudo vim/etc/mysql/mysql.conf.d/mysqld.cnf
Add a row under [Mysqld] Character_set_server=utf8
Configuration file Excerpt:
[Mysqld]
#
# * Basic Settings
#
user = MySQL
Pid-file =/var/run/mysqld/mysqld.pid
Socket =/var/run/mysqld/mysqld.sock
Port = 3306
Basedir =/usr
DataDir =/var/lib/mysql
Tmpdir =/tmp
Lc-messages-dir =/usr/share/mysql
Character_set_server=utf8 is this line, the original is not, to manually add!
Skip-external-locking
#
Copy the above file to/ETC/MYSQL/MY.CNF
~$ sudo cp/etc/mysql/mysql.conf.d/mysqld.cnf/etc/mysql/my.cnf
Restarting the database service
~$/etc/init.d/mysql Restart
If you look at the character set, the following results will be successful.
Mysql> Show variables like ' collation_% ';
+----------------------+-----------------+
| variable_name | Value |
+----------------------+-----------------+
| collation_connection | Utf8_general_ci |
| Collation_database | Utf8_general_ci |
| Collation_server | Utf8_general_ci |
+----------------------+-----------------+
3 Rows in Set (0.00 sec)

Mysql> Show variables like ' character_set_% ';
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
8 rows in Set (0.01 sec)

Java Learning Note--linux installation configuration MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.