Home  >  Article  >  Database  >  How to configure the installation-free version of mysql

How to configure the installation-free version of mysql

PHPz
PHPzOriginal
2023-04-20 10:11:171836browse

MySQL is an open source relational database management system that has become the first choice of many web developers and data scientists. In daily development work, we inevitably need to install and configure MySQL, and the process of configuring MySQL is often tedious and time-consuming. However, if you have an installation-free version of MySQL, you can do everything with less effort.

1. Download the MySQL installation-free version

First, download the latest MySQL installation-free version from the official website of MySQL (https://dev.mysql.com/downloads/mysql/) program.

After downloading, unzip it to any directory.

2. Configure MySQL on Windows

  1. Configure environment variables

Add the MySQL bin directory to the system environment variables. Enter system properties -> Advanced system settings -> Environment variables -> Edit system variables, find the Path variable, and add the MySQL bin directory.

  1. Configure the my.ini configuration file

Copy the decompressed my.ini file to the MySQL decompression directory. For example, copy the my.ini file to the C:\mysql-8.0.21-winx64 directory, and then modify the configuration file.

Edit the my.ini configuration file and specify the MySQL data storage directory:

datadir=C:/mysql-8.0.21-winx64/data

The data directory here is created manually after decompressing MySQL. And some parameters need to be further configured to improve the performance of the system, for example:

character-set-server=utf8
max_connections=1000
wait_timeout=600
innodb_buffer_pool_size=128M
  1. Start MySQL

Change the current directory to C:\mysql- 8.0.21-winx64\bin, and then execute the following command to start MySQL:

mysqld --initialize-insecure --user=mysql
mysqld --console

Then you can use the mysql command on the command line to connect to the database:

mysql -u root -p
  1. Configuration MySQL service

Enter the bin directory of MySQL on the command line and execute the following command to configure MySQL as a system service:

mysqld --install

Then you can see it in the Windows service The MySQL service can be started manually.

3. Configure MySQL on Linux

  1. Configure the my.cnf configuration file

Copy the decompressed my.cnf file to the MySQL decompression Under contents. For example, copy the my.cnf file to the /usr/local/mysql directory, and then modify the configuration file:

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
datadir=/usr/local/mysql/data
infinity
default_storage_engine=INNODB

[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid

[mysql]
no-auto-rehash
  1. Initialize MySQL

Execute the following on the command line Command to initialize MySQL:

/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize-insecure --user=mysql

Among them, --basedir and --datadir specify the MySQL installation directory and data storage directory respectively.

  1. Start MySQL

Execute the following command in the command line to start MySQL:

/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

Then you can use the mysql command in the command line to connect to Database:

mysql -u root -p
  1. Set as system service

If you need to configure MySQL as a system service, you need to add the following command to /etc/rc.local first:

/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

Then execute the following command on the command line to configure MySQL as a system service:

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
service mysql start

Summary

Configuring the MySQL installation-free version through the above method can avoid tedious steps The installation process allows you to start your development work faster. Of course, this method is not suitable for every project, but is more suitable for projects that require frequent testing and debugging.

Finally, it is recommended that you read the MySQL official documentation before operating to ensure that your operations are correct and avoid unnecessary errors.

The above is the detailed content of How to configure the installation-free version of mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn