MySQL cross-platform (WINDOWS,LINUX,MAC) usage and installation

Source: Internet
Author: User
Tags change settings dedicated server

MySQL is actually a cross-platform lightweight database, usually development will use a lot. There are writing programs that you might want to develop across platforms, and then I'll show you how to use MySQL across platforms.

Here the so-called cross-platform is Windows,linux,mac common with a set of MySQL configuration including all users and databases and so on.


Principle: In fact, it is very simple, is configured to use the same folder to store. It is also possible to know that MySQL installation files and run the program is not important, backup time as long as the backup of the folder to store data, the next time you reload or change the configuration, set to this directory.


Here are the installation tutorials for each platform:

Installation Preface: This tutorial is used in the zip version of the installation, so more convenient, cross-platform easier.

Installation of the required profile information, Windows under the file named My.ini,mac and Linux under the MY.CNF

# for advice The change settings
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# * * * Don't EDIT this FILE. It ' s a template which'll be copied to the
# * * * default location during install, and would be replaced if you
# * * * * Upgrade to a newer version of MySQL.

[Mysqld]

# Remove Leading # and set to the amount of RAM for the most important data
# Cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove Leading # to turn on a very important data integrity option:logging
# Changes to the binary log between backups.
# Log_bin

# These is commonly set, remove the # and set as required.
Basedir = * Here to fill in the zip decompression of the Mysql directory, Windows under the directory is best to quote such as "D:\\mysqldata", Mac and Linux do not need quotation marks, such as/media/*/mysql. Same below
DataDir = * Here to fill in the directory of information, cross-platform key here, to cross the platform here to fill the same directory under different platforms on the line, the directory of their own random *
Port = 3306
# server_id = ...
Character_set_server=utf8

# Remove Leading # To set options mainly useful for reporting servers.
# The server defaults is faster for transactions and fast selects.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

Sql_mode=no_engine_substitution,strict_trans_tables

[Client]
port=3306
Default-character-set=utf8


First, Windows

Configuration of the 1.my.ini

Modify
Basedir = "D:\\mysql" (unzipped Mysql directory)
DataDir = "D:\\mysqldata" (MySQL information and database storage directory)

My.ini into the extracted MySQL directory

2. Configuration of the environment
#例如: Environment variable setting, new variable name mysql_home, variable value is MYSQL installation directory path, here is D:\Mysql (installation path); Add%mysql_home%\bin to the path variable of the environment variable;

3. Open the command line with administrator privileges, execute: mysqld--initialize--user=mysql--console, and record the password

4. Execute installation Service command: Mysqld-install

5. Execute the START service command: net start MySQL

6. Execution: Mysql-u root-p

7. Enter the password you just made

8. Execute Password change command: Set password = password (' password ');(plus the last semicolon)

If MySQL has already been installed, DataDir has used this directory on other platforms or backed up directories, saving 3 and 6~8.


Second, Mac

Configuration of the 1.MY.CNF

Modify
Basedir =/volumes/*/mysql (unzipped Mysql directory)
DataDir =/volumes/*/mysqldata (MySQL information and database storage directory)

Copy my.cnf to/etc directory, you can use the CP command under root privileges or sudo

2. Configure Environment variables

Su
Password
Nano/etc/profile
Add after file
{
Mysql_home= "/volumes/*/mysql" (MySQL path)
Path= ".: $PATH: $MYSQL _home/bin"
Export Mysql_home
}
Save exit
Source/etc/profile

3. Open the command line with administrator privileges, execute: mysqld--initialize--user=mysql--console, and record the password

4. Execute installation Service command: Mysqld-install

5. Execute the START Service command: CD to the corresponding MySQL directory to execute./bin/mysqld_safe (does not turn on the MySQL service automatically, so use the time needed to enable, preferably write an sh executable file)

6. Execution: Mysql-uroot-p

7. Enter the password you just made

8. Execute Password change command: Set password = password (' password ');(plus the last semicolon)

9. Extension: Close the MySQL CD to the appropriate MySQL directory to execute mysqladmin-uroot-p shutdown

If MySQL has already been installed, DataDir has used this directory on other platforms or backed up directories, saving 3 and 6~8.


Third, Linux

Configuration of the 1.MY.CNF

Modify
Basedir =/media/*/mysql (unzipped Mysql directory)
DataDir =/media/*/mysqldata (MySQL information and database storage directory)

Copy my.cnf to/etc directory, you can use the CP command under root privileges or sudo

2. Configure Environment variables

Su
Password
sudo gedit ~/.BASHRC
After the file is added
{
Export Mysql_home=/media/qingyi/developmenttools/linux/mysql (MYSQL path)
Export Path=${mysql_home}/bin: $PATH
}
Save exit
#source ~/.BASHRC

3. Open the command line with administrator privileges, execute: mysqld--initialize--user=mysql--console, and record the password

4. Execute installation Service command: Mysqld-install

5. Execute the START Service command: CD to the appropriate MySQL directory to execute./bin/mysqld_safe

6. Execution: Mysql-uroot-p

7. Enter the password you just made

8. Execute Password change command: Set password = password (' password ');(plus the last semicolon)

9. Extension: Close the MySQL CD to the appropriate MySQL directory to execute mysqladmin-uroot-p shutdown

If MySQL has already been installed, DataDir has used this directory on other platforms or backed up directories, saving 3 and 6~8.

MySQL cross-platform (WINDOWS,LINUX,MAC) usage and installation

Related Article

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.