UbuntuServerUbuntu
bitsCN.com第一次接触服务器版Linux,也是第一次用命令行安装二进制mysql,两天一夜,比较痛苦。留做备忘!
首先,下载二进制版本的mysql包: http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
因为Ubuntu Server上 wget比较慢,所以我是直接在windows用迅雷下载好,然后WinSCP上传到服务器的,看各自喜好了。
上正题。
包放在~/Download目录下,全部安装命令如下:
1、解压tar.gz
tar –xzf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
2、重命名解压的文件夹
mv mysql-5.6.10-linux-glibc2.5-x86_64 mysql
3、将mysql文件夹移动到/usr/local目录下
sudo mv mysql /usr/local
4、进入mysql目录
cd /usr/local/mysql
5、增加mysql用户组
sudo groupadd mysql
6、增加mysql用户
sudo useradd -r -g mysql mysql
7、将mysql文件夹own及grp变更为mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
8、执行mysql安装脚本
sudo scripts/mysql_install_db --user=mysql
(若未安装libaio包,会有一个报错提示,安装libaio-dev后,再运行脚本即可)
sudo apt-get install libaio-dev
9、将目录权限变更回来,仅保留data目录为mysql用户
sudo chown -R root .
sudo chown -R mysql data
10、将mysql配置文件拷贝到etc目录(全局配置)
注意:5.6版本的默认配置文件名称由原先的my-medium变更为了my-default。
sudo cp support-files/my-default.cnf /etc/my.cnf
11、启动mysql
sudo bin/mysqld_safe --user=mysql &
12、初始化mysql root用户密码
sudo bin/mysqladmin -u root password '密码文字'
13、复制mysql.server脚本到/etc/init.d(初始化服务,有些人喜欢改成mysqld,在这里改就可以)
sudo cp support-files/mysql.server /etc/init.d/mysql.server
14、查看mysql运行状态
sudo service mysql.server status
如果运行正常,会显示 MySQL running。
如果显示 not running,应该是前面没有启动服务,可直接用service mysql.server start启动
sudo service mysql.server [status|start|stop]
15、让mysql开机启动[defaults],取消开机启动[remove]
sudo update-rc.d -f mysql.server defaults [remove]
16、将mysql/bin/mysql命令加入到用户命令中,或将mysql/bin目录加入path
加入用户命令:
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
加入环境变量:
export PATH=$PATH:/usr/local/mysql/bin
17、允许root用户远程登录
1>进入mysql: mysql –u root –p
2>改变数据库: use mysql;
3>从任意主机登录: grant all privileges on *.* to root@"%" identified by "密码文字" with grant option;
4>从指定主机登录: grant all privileges on *.* to root@"192.168.1.101" identified by "passw0rd" with grant option;
5>授权生效: flush privileges;
6>查看host为%授权是否添加: select * from user;
18、找个客户端去试试吧。

The main difference between MySQL and SQLite is the design concept and usage scenarios: 1. MySQL is suitable for large applications and enterprise-level solutions, supporting high performance and high concurrency; 2. SQLite is suitable for mobile applications and desktop software, lightweight and easy to embed.

Indexes in MySQL are an ordered structure of one or more columns in a database table, used to speed up data retrieval. 1) Indexes improve query speed by reducing the amount of scanned data. 2) B-Tree index uses a balanced tree structure, which is suitable for range query and sorting. 3) Use CREATEINDEX statements to create indexes, such as CREATEINDEXidx_customer_idONorders(customer_id). 4) Composite indexes can optimize multi-column queries, such as CREATEINDEXidx_customer_orderONorders(customer_id,order_date). 5) Use EXPLAIN to analyze query plans and avoid

Using transactions in MySQL ensures data consistency. 1) Start the transaction through STARTTRANSACTION, and then execute SQL operations and submit it with COMMIT or ROLLBACK. 2) Use SAVEPOINT to set a save point to allow partial rollback. 3) Performance optimization suggestions include shortening transaction time, avoiding large-scale queries and using isolation levels reasonably.

Scenarios where PostgreSQL is chosen instead of MySQL include: 1) complex queries and advanced SQL functions, 2) strict data integrity and ACID compliance, 3) advanced spatial functions are required, and 4) high performance is required when processing large data sets. PostgreSQL performs well in these aspects and is suitable for projects that require complex data processing and high data integrity.

The security of MySQL database can be achieved through the following measures: 1. User permission management: Strictly control access rights through CREATEUSER and GRANT commands. 2. Encrypted transmission: Configure SSL/TLS to ensure data transmission security. 3. Database backup and recovery: Use mysqldump or mysqlpump to regularly backup data. 4. Advanced security policy: Use a firewall to restrict access and enable audit logging operations. 5. Performance optimization and best practices: Take into account both safety and performance through indexing and query optimization and regular maintenance.

How to effectively monitor MySQL performance? Use tools such as mysqladmin, SHOWGLOBALSTATUS, PerconaMonitoring and Management (PMM), and MySQL EnterpriseMonitor. 1. Use mysqladmin to view the number of connections. 2. Use SHOWGLOBALSTATUS to view the query number. 3.PMM provides detailed performance data and graphical interface. 4.MySQLEnterpriseMonitor provides rich monitoring functions and alarm mechanisms.

The difference between MySQL and SQLServer is: 1) MySQL is open source and suitable for web and embedded systems, 2) SQLServer is a commercial product of Microsoft and is suitable for enterprise-level applications. There are significant differences between the two in storage engine, performance optimization and application scenarios. When choosing, you need to consider project size and future scalability.

In enterprise-level application scenarios that require high availability, advanced security and good integration, SQLServer should be chosen instead of MySQL. 1) SQLServer provides enterprise-level features such as high availability and advanced security. 2) It is closely integrated with Microsoft ecosystems such as VisualStudio and PowerBI. 3) SQLServer performs excellent in performance optimization and supports memory-optimized tables and column storage indexes.


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.