What is mysql cross-platform?
mysql跨平台指的是Windows、Linux和Mac共同用一套Mysql配置包括所有用户和数据库等;mysql既能够作为一个单独的应用程序应用在客户端服务器网络环境中,也能够作为一个库而嵌入到其他的软件中。
本教程操作环境:Windows10系统、mysql8版本、Dell G3电脑。
mysql跨平台是什么?
Mysql跨平台(Windows,Linux,Mac)使用与安装
MySQL其实是一个跨平台的轻量级数据库,平时开发会用到很多。有写程序可能要跨平台开发,接下来我就介绍一下如何跨平台使用Mysql。
这里所谓的跨平台就是Windows,Linux,Mac共同用一套Mysql配置包括所有用户和数据库等等。
原理:其实很简单,就是配置的时候使用同一个文件夹存放即可。由此也可以知道,Mysql的安装文件和运行程序并不重要,备份的时候只要备份存放数据的文件夹即可,下次重装或换设配时,设置到这个目录即可。
下面是各个平台的安装教程:
安装前言:本教程中使用的都是zip版的安装方式,这样更加方便,跨平台更容易。
安装中所需要的配置文件信息,Windows下文件命名为My.ini,Mac和Linux下为My.cnf
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will 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 total 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 are commonly set, remove the # and set as required.
basedir = *此处填写zip解压的Mysql目录,Windows下目录最好打引号如"D:\\MysqlData",Mac和Linux不需要引号,如/media/*/Mysql。下同*
datadir = *此处填写存放信息的目录,跨平台关键就在这里,要跨平台在这里填写不同平台下的同一个目录路径就行了,目录自己随意*
port = 3306 # server_id = ..... character_set_server=utf8 # Remove leading # to set options mainly useful for reporting servers. # The server defaults are 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
一、Windows
1.my.ini的配置
修改
basedir = "D:\\Mysql"(解压的mysql目录) datadir = "D:\\MysqlData"(Mysql信息和数据库的存放目录)
my.ini放到解压的mysql的目录下
2.环境的配置
#例如:环境变量设置, 新建变量名 MYSQL_HOME , 变量值为 MySQL 安装目录路径, 这里为D:\Mysql(安装路径);在环境变量的 Path 变量中添加 %MYSQL_HOME%\bin;
3.以管理员权限打开命令行,执行: mysqld --initialize --user=mysql --console,并记录下密码
4.执行安装服务命令: mysqld -install
5.执行启动服务命令: net start mysql
6.执行:mysql -u root -p
7.输入刚才的密码
8.执行改密码命令:set password = password('password');(加上最后的分号)
如果已经安装过mysql了,datadir中在其他平台上使用过这个目录了或者备份过来的目录,省去3和6~8。
二、Mac
1.my.cnf的配置
修改
basedir = /Volumes/*/Mysql (解压的mysql目录) datadir = /Volumes/*/MysqlData (Mysql信息和数据库的存放目录)
复制my.cnf到/etc目录下,可在root权限或sudo下使用cp命令
2.配置环境变量
su
密码
nano /etc/profile
在文件后面添加
{ MYSQL_HOME="/Volumes/*/mysql"(mysql路径) PATH=".:$PATH:$MYSQL_HOME/bin" export MYSQL_HOME }
保存退出
source /etc/profile
3.以管理员权限打开命令行,执行: mysqld --initialize --user=mysql --console,并记录下密码
4.执行安装服务命令: mysqld -install
5.执行启动服务命令: cd到相应的mysql目录执行./bin/mysqld_safe(不会开机自动启用Mysql服务,所以用到的时候需要启用,最好写一个sh执行文件)
6.执行:mysql -uroot -p
7.输入刚才的密码
8.执行改密码命令:set password = password('password');(加上最后的分号)
9.扩展:关闭MySql cd到相应的mysql目录执行mysqladmin -uroot -p shutdown
如果已经安装过mysql了,datadir中在其他平台上使用过这个目录了或者备份过来的目录,省去3和6~8。
三、Linux
1.my.cnf的配置
修改
basedir = /media/*/Mysql (解压的mysql目录) datadir = /media/*/MysqlData (Mysql信息和数据库的存放目录)
复制my.cnf到/etc目录下,可在root权限或sudo下使用cp命令
2.配置环境变量
su
密码
sudo gedit ~/.bashrc
在文件后添加
{ export MYSQL_HOME=/media/qingyi/DevelopmentTools/Linux/mysql(mysql路径) export PATH=${MYSQL_HOME}/bin:$PATH }
保存退出
#source ~/.bashrc
3.以管理员权限打开命令行,执行: mysqld --initialize --user=mysql --console,并记录下密码
4.执行安装服务命令: mysqld -install
5.执行启动服务命令: cd到相应的mysql目录执行./bin/mysqld_safe
6.执行:mysql -uroot -p
7.输入刚才的密码
8.执行改密码命令:set password = password('password');(加上最后的分号)
9.扩展:关闭MySql cd到相应的mysql目录执行mysqladmin -uroot -p shutdown
如果已经安装过mysql了,datadir中在其他平台上使用过这个目录了或者备份过来的目录,省去3和6~8。
【相关推荐:mysql视频教程】
The above is the detailed content of What is mysql cross-platform?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA
