Home Database Mysql Tutorial 【转】ubuntu MySQL采取apt-get install安装目录

【转】ubuntu MySQL采取apt-get install安装目录

Jun 07, 2016 pm 04:25 PM
apt-get mysql ubuntu

【转】ubuntu MySQL采用apt-get install安装目录 一). ? ubuntu下mysql安装布局:/usr/bin????????????????????? 客户端程序和mysql_install_db /var/lib/mysql??????????? 数据库和日志文件 /var/run/mysqld??????? 服务器 /etc/mysql ? ? ? ? ????? 配置文件

【转】ubuntu MySQL采用apt-get install安装目录
一).?ubuntu下mysql安装布局: /usr/bin????????????????????? 客户端程序和mysql_install_db
/var/lib/mysql??????????? 数据库和日志文件
/var/run/mysqld??????? 服务器
/etc/mysql ? ? ? ? ????? 配置文件my.cnf
/usr/share/mysql?????? 字符集,基准程序和错误消息
/etc/init.d/mysql??????? 启动mysql服务器 二).?设置mysql服务器随开关机自动启动和关闭: 系统 -> 系统管理 -> 服务
进行到“服务设置”窗口后,激活mysql数据库服务即可 三).?修改mysql数据库文件的存储目录: ? MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/home/data下需要进行下面几步: 1、home目录下建立data目录

1

2

cd /home

mkdir data

Copy after login
2、把MySQL服务进程停掉:

1

mysqladmin -u root -p shutdown

Copy after login
3、把/var/lib/mysql整个目录移到/home/data

1

mv /var/lib/mysql /home/data/

Copy after login
这样就把MySQL的数据文件移动到了/home/data/mysql下 4、找到my.cnf配置文件 如果/etc/目录下没有my.cnf配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为my.cnf)中。命令如下:

1

[root@test1 mysql]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

Copy after login
5、编辑MySQL的配置文件/etc/my.cnf 为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:/home/mysql/mysql.sock 。操作如下:

1

2

3

4

5

vi  my.cnf  (用vi工具编辑my.cnf文件,找到下列数据修改之)

# The MySQL server

[mysqld]  port = 3306

#socket  = /var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)

socket  = /home/data/mysql/mysql.sock (加上此行)

Copy after login
6、修改MySQL启动脚本/etc/init.d/mysql 最后,需要修改MySQL启动脚本/etc/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:home/data/mysql。

1

2

3

[root@test1 etc]# vi /etc/init.d/mysql

#datadir=/var/lib/mysql(注释此行)

datadir=/home/data/mysql (加上此行)

Copy after login
7、重新启动MySQL服务
/etc/init.d/mysql start 或用reboot命令重启Linux 如果工作正常移动就成功了,否则对照前面的7步再检查一下。还要注意目录的属主和权限。 四).?配置mysql数据库的INNODB存储引擎: 1 . 查看mysql存储引擎情况: 登录mysql数据库,在mysql>提示符下搞入show engines;命令。发现: InnoDB | YES,说明此mysql数据库服务器支持InnoDB引擎。
2. 设置InnoDB为默认引擎:在配置文件my.cnf中的 [mysqld] 下面加入default-storage-engine=INNODB 一句,保存。
3. 重启mysql服务器:mysqladmin -u root -p shutdown(回车),sudo /etc/init.d/mysql start(回车)。
4. 登录mysql数据库,在mysql>提示符下搞入show engines;命令。如果出现 InnoDB |DEFAULT,则表示我们 设置InnoDB为默认引擎成功。
ps:?这里我用重启命令sudo /etc/init.d/mysql restart,出现错误信息, 所以用了上面(步骤3)那种关闭服务又启动的笨方法。 ? 转自:http://m.blog.csdn.net/blog/goodspringin/9258883
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

How to create navicat premium How to create navicat premium Apr 09, 2025 am 07:09 AM

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

Can I retrieve the database password in Navicat? Can I retrieve the database password in Navicat? Apr 08, 2025 pm 09:51 PM

Navicat itself does not store the database password, and can only retrieve the encrypted password. Solution: 1. Check the password manager; 2. Check Navicat's "Remember Password" function; 3. Reset the database password; 4. Contact the database administrator.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

How to view database password in Navicat for MariaDB? How to view database password in Navicat for MariaDB? Apr 08, 2025 pm 09:18 PM

Navicat for MariaDB cannot view the database password directly because the password is stored in encrypted form. To ensure the database security, there are three ways to reset your password: reset your password through Navicat and set a complex password. View the configuration file (not recommended, high risk). Use system command line tools (not recommended, you need to be proficient in command line tools).

How to create a new connection to mysql in navicat How to create a new connection to mysql in navicat Apr 09, 2025 am 07:21 AM

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

How to execute sql in navicat How to execute sql in navicat Apr 08, 2025 pm 11:42 PM

Steps to perform SQL in Navicat: Connect to the database. Create a SQL Editor window. Write SQL queries or scripts. Click the Run button to execute a query or script. View the results (if the query is executed).

See all articles