Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lesson record of installing MySQL 8.0.16 under MAC

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

problem

It took more than two days to solve the problem! Originally, I have used MySQL in several environments, and I am also familiar with several other relational databases, which I thought would cost a little bit of installation time. However, to sum up, there is still too little knowledge about MAC, which leads to a lot of detours. It is now recorded here. Interested friends can refer to it.

I am downloading the latest mysql-8.0.16-macos10.14-x86_64.dmg installation from the official Oracle website. There was no problem with the installation process at the beginning, much the same as other .dmg files.

However, after the installation, there was an error running the following command on the MAC terminal:

Mysql-uroot-p

Or just run the mysql command, resulting in the following error:

This error is classic and has been prompted for installation and initial use of different versions of MYSQL on many types of UNIX platforms!

I have been struggling with this mistake for quite a long time!

Solving process

After several failed attempts, I noticed that some online articles mentioned the method of analyzing the error tracking log. Therefore, I also have the patience to track and analyze the error log file mysqld.local.err.

Note that the security of MYSQL 8.0 (which has a lot to do with installation on the MAC platform) is getting higher and higher, and you need to constantly modify permissions in order to analyze the content in its corresponding path. Finally, observe the following repeated prompts in this file:

[System] [MY-010116] [Server] / usr/local/mysql/bin/mysqld (mysqld 8.0.16) starting as process 1036

2019-05-09T00:52:09.981310Z 0 [Warning] [MY-013242] [Server]-- character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.

2019-05-09T00:52:09.982012Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for / usr/local/mysql/data/ is case insensitive

2019-05-09T00:52:10.356462Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-05-09T00:52:10.356884Z 0 [ERROR] [MY-010273] [Server] Could not create unix socket lock file / tmp/mysql.sock.lock.

2019-05-09T00:52:10.356892Z 0 [ERROR] [MY-010268] [Server] Unable to setup unix socket lock file.

2019-05-09T00:52:10.357090Z 0 [ERROR] [MY-010119] [Server] Aborting

2019-05-09T00:52:11.822090Z 0 [System] [MY-010910] [Server] / usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.16) MySQL Community Server-GPL.

Combined with the "system preferences" when the MYSQL icon is opened, it is found that the MYSQL is connected and disconnected every few seconds, which is consistent with the logging here.

Next, search using the keyword "Could not create unix socket lock file / tmp/mysql.sock.lock" mentioned in the error above.

Because some students in the online article have solved the problem, but due to different versions, and some understanding is not very in place, resulting in I also follow a lot of blind walk.

The answer is that the error above is due to the lack of write access to the / tmp directory.

Therefore, run the following command:

Sudo chown-R mysql:mysql / tmp/

Run the following command on the command line again to successfully start mysql-- through the panel corresponding to the MYSQL icon in the system preferences above.

Sudo mysqld_safe

The role of the mysqld_safe command file will not be discussed here, please search for answers by yourself.

Note: after the initial installation of MYSQL through the wizard above, the configuration file my.cnf is not automatically created in the current version, but needs to be created by yourself. Its typical location is

/ etc path. The content of this document is also found on the Internet. Please refer to it and list it below:

[client] default-character-set=utf8#password = root password port = 3306 socket = / tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] character-set-server=utf8 init_connect='SET NAMES utf8 port = 3306 socket = / tmp/mysql.sock skip-external-locking key_buffer_size = 16m max_allowed_packet = 1Mtable_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_ Size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8m character-set-server=utf8 init_connect='SET NAMES utf8'# Don't listen on a TCP/IP port at all. This can be a security enhancement # if all processes that need to connect to mysqld run on the same host.# All interaction with mysqld must be made via Unix sockets or named pipes.# Note that using this option without enabling named pipes on Windows# (via the "enable-named-pipe" option) will render mysqld uselesswoods networking # Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin# binary logging format-mixed recommended binlog_format=mixed # required unique id between 1 and 2 ^ 32-1 # defaults to 1 if Master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave You can choose between # two methods: # # 1) Use the CHANGE MASTER TO command (fully described in our manual)-# the syntax is: # # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, # MASTER_USER=, MASTER_PASSWORD= # # where you replace, by quoted strings and # by the master's port number (3306 by default). # # Example: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR# # 2) Set the variables below. However, in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # change in this file to the variables' values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason You may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2 ^ 32-1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted # server-id = 2 # The replication master for this slave-required # master-host = # # The username The slave will use for authentication when connecting # to the master- required # master-user = [mysqldump] quick max_allowed_packet = 16m [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL # safe-updates default-character-set=utf8 [myisamchk] key_buffer_size = 20m Sort_buffer_size = 20m read_buffer = 2m write_buffer = 2m [mysqlhotcopy] interactive-timeout

Note: in the configuration file above, the most critical line in our area of interest is:

Socket = / tmp/mysql.sock

With regard to the file mysql.sock, you will find a lot on the website, and I won't repeat it here.

In short, after the above operation, we have the right to operate on the / tmp path, and after starting mysql normally, we will generate this file (this file does not exist in advance! ).

In addition, the online article also mentions the following descriptions:

In the configuration of my.cnf file, at the beginning I use Mac built in the text editor software to create my.cnf file, but the file encoding format is utf-8, when reading in MySQL will report an error, and then find relevant information to find MySQL configuration file needs when ASNI/ASCII format, so I directly in the terminal with the vim command to create a my.cnf file, and then write the configuration, on it.

First open the terminal, cd to the / etc path, and then use the command

Sudo cp ~ / Desktop/my.cnf. / (I put the my.cnf file on the desktop)

Copy the file to the / etc path and modify the file permissions

Sudo chmod 664 my.cnf

Be sure to change it to 664, otherwise MySQL will make an error when reading the file.

Very meticulous, very good. That is, we should use the vi command from the command line to create this configuration file and make sure it uses the ASCII format. By default, files created using vi are naturally in plain text format and meet the requirements. In addition, you can easily use the file command to view the format of a file.

At this point, the problem has been solved by 60%, or 80%. At this point, the configuration file is created and the mysql service can start normally.

However, there is still an error running the following command:

Mysql-uroot-p

The error is as follows:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' ``

In the process of solving the above problems, the greatest contribution is the important reference of the article https://www.cnblogs.com/hamsterPP/p/5274052.html.

However, the script command used when finally changing the root user password is out of date, and instead of using the UPDATE command, the ALTER command is used instead. This is also clearly stated on the official website.

The command is as follows:

ALTER USER 'root'@'localhost' IDENTIFIED BY' MyNewPass'

However, be sure to run the following refresh command before running the above command:

Flush privileges

Note that as mentioned in the important reference article above, you need to open two console windows during the process of resetting (creating) your root password. Remember!

The last lesson: the truth learned from paper is not profound, you must practice it yourself!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report