In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is how to install MySQL configuration in linux, I believe most people have not learned this skill, in order to let everyone learn, to summarize the following content, not much to say, look down together.
1 Introduction
There are many ways to install MySQL under Linux, including installing it in the repository (yum,apt,zypper), installing it in the package (rpm,deb), installing it in the docker mode, extracting and installing it from the compressed package, compiling and installing it from the source code, and here is the last one, compiling and installing it from the source code.
Compilation and installation requires a lot of patience and time, and will encounter a lot of strange problems, therefore, requires great perseverance, it is likely that ten thousand failures will not come in exchange for a success, please be mentally prepared.
2 Preparations
The following are installation requirements, already installed can skip.
cmakeboostgccncursesopensslbisondoxygen2.1 gcc
Linux is generally equipped with gcc, the minimum required version is 5.3, if you need to update, you can see another blog of the author.
2.2 boost
Boost does not need to be installed manually. It will be automatically downloaded and installed when running cmake script later. Of course, it can also be installed manually. The official website documentation says that a specific version is required. MySQL Server 8.0.19 here requires 1.70.0. The latest boost library is 1.72.0.
2.3 cmake
See another blog post by the author.
2.4 other
Other general use of the repository installation can, of course, each one can also be tossed from the source code installation, you like it.
2.4.1 Red Hat
7.x:
sudo yum install -y bison bzip2 git hostname ncurses-devel openssl openssl-devel pkgconfig tar wget zlib-devel doxygen
8.x:
sudo yum install -y bison bzip2 git hostname ncurses-devel openssl openssl-devel pkgconfig tar wget zlib-devel dooxygen diffutils rpcgen make libtirpc-devel2.4.2 ubuntu system sudo apt-get updatesudo apt-get install -y bison git hostname libncurses-dev libssl-dev make openssl pkg-config dooxygen3 download and decompression 3.1 download
MySQL Server Download
I don't know what the difference is between boost and non-boost. When using cmake later, you need to download boost manually, so just choose one at random. God's people are grateful, and I am grateful.
3.2 Unzip tar -zxvf mysql-boost-8.0.19.tar.gzcd mysql-8.0.193.3 Create temporary bld folder mkdir bldcd bld4 compile and install 4.1 cmakemake.. \-DDOWNLOAD_BOOST=1 \-DWITH_BOOST=. \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DENABLED_LOCAL_INFILE=ON \-DWITH_SSL=system \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/server \-DMYSQL_DATADIR=/usr/local/mysql/data \-DMYSQL_TCP_PORT=3306 \
Boosts installed do not require:
-DDOWNLOAD_BOOST=1 -DWITH_BOOST
Installation location and data location customized according to needs:
-DCMAKE_INSTALL_PREFIX=-DMYSQL_DATADIR=
4.2 compile make -j n
n is the number of CPU cores. If it fails, please use it directly
make
Compilation takes a long time here, and there are progress tips.
4.3 install sudo make install
Here I encountered a problem with libstdc++.so.6 library, MySQL Server 8.0.19 installation requires GLIBCXX_3.4.25.
You can see the path to libstdc++.so.6:
sudo find / -name lidstdc++.so.6
After finding the path:
strings /xxx/libstdc++.so.6 | grep GLIBCXX
I only have GLIBCXX_3.4.22 here. Since gcc was manually updated before, in the lib directory of gcc:
So just copy this libstdc++.so.6 to/lib/as prompted by sudo make install:
sudo cp libstdc++.so.6 /lib/x86_64-linux-gnu/
Another solution (for Ubuntu) is to add the ppa source and update:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get updatesudo apt-get upgradesudo apt-get dist-upgrade
The others are similar, updating gcc to manually specify lib locations.
Installation successful.
4.4 Test make test
The test passed.
5 Configuration MySQL
MySQL configuration is required after installation.
5.1 new user group and user sudo groupadd mysqlsudo useradd -r -g mysql -s /bin/false mysql5.2 modify data directory owner and permissions
The data catalogue is modified as required.
sudo chown mysql:mysql /usr/local/mysql/datasudo chmod 777 /usr/local/mysql/data
The official document here says 750 permissions, but there will be no writeable error later, 755 will not work, so it is directly changed to 777.
5.3 my.cnf
my.cnf is installed in/etc or/etc/mysql. By default, there is a my.cnf installed in/etc/mysql:
/etc/mysql/my.cnf is the global configuration,~/.my.cnf is the user-specific configuration, here directly modify/etc/mysql/my.cnf:
[mysqld]port=3306basedir=/usr/local/mysql/serverdatadir=/usr/local/mysql/datacharacter-set-server=utf8mb4[mysql]default-character-set=utf8[client]port=3306default-character-set=utf8
Parameters can be added later as needed, here if utf8 is used:
[mysqld]character-set-server=utf8
There will be a warning, because MySQL 5.5.3 after the addition of utf8mb4, mb4 is the meaning of most bytes 4, specifically for compatibility with four-byte unicode, utf8 refers to utf8mb3, the maximum supported utf8 encoding character length is 3 bytes, warning prompt changed to utf8mb4:
[mysqld]character-set-server=utf8mb4
(Additional reading: utf8 and utf8mb4)
5.4 initialization
Go to bin under MySQL Server installation directory:
mysqld --initialize-insecure --user=mysql
Here-insecure is used because there is no need to enter a random password. Of course, you can also remove insecure, so there will be a random password, to remember.
mysqld --initialize --user=mysql
5.5 ssl and rsa support (optional) mysql_ssl_rsa_setup
This general server is required.
5.6 Open service mysqld_safe --user=mysql &5.7 Modify root password
Log in with root first
mysql -u root --skip-password
If initialized, enter
mysql -u root -p
Enter the temporary password.
Once inside, use alter to change the root password:
alter 'root'@'localhost' identified by 'xxxxx'5.8 Test
Use the mysqlshow and mysqladmin that come with it:
mysqladmin -u root -p versionmysqlshow -u root -p
MySQL Server 8.0.19 is installed.
6 Subsequent processing 6.1 Deleting files
You can delete the installation file first:
sudo rm -rf mysql-8.0.19*
In addition, according to the boost directory at the time of cmake just now, the boost library can be deleted:
sudo rm -rf boost_1_70_0*
Because the documentation says only boost is needed to build, not use it.
6.2 alias
Add an alias just for convenience, here the author's practice is actually very lazy, default root login, modify ~/.bash_aliases:
alias mysqld="/usr/local/mysql/bin/mysqld_safe --user=mysql &"alias mysql="/usr/local/mysql/bin/mysql -u root -p"
Before using MySQL, use mysqld to start the service to hang up the background, and then log in using mysql, the default root user.
Of course, the more lazy way is
alias mysql="/usr/local/mysql/bin/mysql -u root --password=xxxx"
You don't even have to enter the password.
The above is how to install Mysql in linux. Is there any harvest after reading it? If you want to know more about it, welcome to pay attention to industry information!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.