mysql 装配 (转)
mysql 安装 (转) 1.安装make编译器(默认系统自带) 下载地址:http://www.gnu.org/software/make/ ? [c-sharp] ?view plaincopy? tar?zxvf?make-3.82.tar.gz?? cd?make-3.82?? ./configure?? make?? make?install?? [c-sharp] ?view plaincopy? tar?zxvf?mak
mysql 安装 (转)1.安装make编译器(默认系统自带)
下载地址:http://www.gnu.org/software/make/
?
[c-sharp]?view plaincopy ?- tar?zxvf?make-3.82.tar.gz??
- cd?make-3.82??
- ./configure??
- make??
- make?install??
- tar?zxvf?make-3.82.tar.gz??
- cd?make-3.82??
- ./configure??
- make??
- make?install??
?
2.安装bison(最好在编译LAMP前安装好所有基类软件)
下载地址:http://www.gnu.org/software/bison/
?
[c-sharp]?view plaincopy ?- tar?zxvf?bison-2.5.tar.gz??
- cd?bison-2.5??
- ./configure??
- make??
- make?install??
- tar?zxvf?bison-2.5.tar.gz??
- cd?bison-2.5??
- ./configure??
- make??
- make?install??
?
3.安装gcc-c++
下载地址:http://www.gnu.org/software/gcc/
?
[c-sharp]?view plaincopy ?- tar?zxvf?gcc-c++-4.4.4.tar.gz??
- cd?gcc-c++-4.4.4??
- ./configure??
- make??
- make?install??
- tar?zxvf?gcc-c++-4.4.4.tar.gz??
- cd?gcc-c++-4.4.4??
- ./configure??
- make??
- make?install??
?
?
4.安装cmake(请下载最新版本安装)
下载地址:http://www.cmake.org/
?
[c-sharp]?view plaincopy ?- tar?zxvf?cmake-2.8.4.tar.gz??
- cd?cmake-2.8.4??
- ./configure??
- make??
- make?install??
- tar?zxvf?cmake-2.8.4.tar.gz??
- cd?cmake-2.8.4??
- ./configure??
- make??
- make?install??
?
5.安装ncurses
下载地址:http://www.gnu.org/software/ncurses/
?
[c-sharp]?view plaincopy ?- tar?zxvf?ncurses-5.8.tar.gz??
- cd?ncurses-5.8??
- ./configure??
- make??
- make?install??
- tar?zxvf?ncurses-5.8.tar.gz??
- cd?ncurses-5.8??
- ./configure??
- make??
- make?install??
?
?
开始安装MySQL,下载地址:http://dev.mysql.com/
这里我在这里下载的mysql-5.6.12.tar.gz
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/
准备工作
?
[c-sharp]?view plaincopy ?- groupadd?mysql??
-
useradd mysql -g mysql -M -s /sbin/nologin??
#增加一个名为CentOS Mysql的用户。-g:指定新用户所属的用户组(group)
-M:不建立根目录
-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。
- groupadd?mysql??
- useradd?-r?-g?mysql?mysql??
?
解压并安装MySQL
?
[c-sharp]?view plaincopy ?- tar?zxvf?mysql-5.6.12.tar.gz??
-
cd?mysql-5.6.12? (以下是一行 这里为了方便大家理解和注释写成换行注释,实际编译中请在换行前 加 " \ "链接)cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ ? #安装路径
-DMYSQL_DATADIR=/usr/local/mysql/data?????? \ ?? #数据文件存放位置
-DSYSCONFDIR=/etc????????????? \ ? ? ? ? ? ? ? ? ? ? ? ? ? ?????? #my.cnf路径
-DWITH_MYISAM_STORAGE_ENGINE=1??? \ ????? #支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ ??? #支持InnoDB引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 \ ?????? #支持Memory引擎
-DWITH_READLINE=1??????????????????? \ ? ? ? ? ? ? ? ? ? ? ? ? #快捷键功能(我没用过)
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock????? \?? #连接数据库socket路径
-DMYSQL_TCP_PORT=3306????????????????? \ ? ? ? ? ? ??? #端口
-DENABLED_LOCAL_INFILE=1??????????? \ ? ? ? ? ? ? ?? #允许从本地导入数据
-DWITH_PARTITION_STORAGE_ENGINE=1? \ ? #安装支持数据库分区
-DEXTRA_CHARSETS=all????????????????? \ ? ? ? ? ? ? ? ? ? #安装所有的字符集
-DDEFAULT_CHARSET=utf8????????????? \ ? ? ? ? ? ? ?? ?? #默认字符
-DDEFAULT_COLLATION=utf8_general_ci
- make??
- make?install??
?
完成后,继续下面的操作
?
[c-sharp]?view plaincopy ?- cd?/usr/local/mysql??
- chown -R mysql:mysql . (为了安全安装完成后请修改权限给root用户)
- scripts/mysql_install_db?--user=mysql (先进行这一步再做如下权限的修改)
- chown?-R root:mysql?.? (将权限设置给root用户,并设置给mysql组, 取消其他用户的读写执行权限,仅留给mysql "rx"读执行权限,其他用户无任何权限)
- chown -R mysql:mysql ./data ? (给数据库存放目录设置成mysql用户mysql组,并赋予chmod -R ug+rwx? 读写执行权限,其他用户权限一律删除仅给mysql用户权限)
- cd?/usr/local/mysql??
- chown?-R?mysql?.??
- chgrp?-R?mysql?.??
- scripts/mysql_install_db?--user=mysql??
- chown?-R?root?.??
?
下面的命令是可选的,将mysql的配置文件拷贝到/etc
?
[c-sharp]?view plaincopy ?- cp?support-files/my-medium.cnf?/etc/my.cnf? (原始老版本是此操作,5.6.12版本的是如下文件地址)
- cp?support-files/my-default.cnf? /etc/my.cnf? (并给/etc/my.cnf +x权限 同时删除 其他用户的写权限,仅仅留给root 和工作组 rx权限,其他一律删除连rx权限都删除)
- cp?support-files/my-medium.cnf?/etc/my.cnf??
?
?
#修改my.cnf配置
??? vim /etc/my.cnf
?? ???
??? #[mysqld] 添加:
??? datadir=/data/mysql
??? default-storage-engine=MyISAM
?
启动mysql:
?
[c-sharp]?view plaincopy ?- bin/mysqld_safe?--user=mysql?&??
- #启动mysql,看是否成功??
- netstat?-tnl|grep?3306??
- bin/mysqld_safe?--user=mysql?&??
- #启动mysql,看是否成功??
- netstat?-tnl|grep?3306??
?
上面是一种启动mysql的方法,还有一种简单的方便,如下:
?
[c-sharp]?view plaincopy ?- #将mysql的启动服务添加到系统服务中??
- cp?support-files/mysql.server?/etc/init.d/mysql??
- #现在可以使用下面的命令启动mysql??
- service?mysql start??
- #停止mysql服务??
- service?mysql stop??
- #重启mysql服务??
- service?mysql restart??
- #将mysql的启动服务添加到系统服务中??
- cp?support-files/mysql.server?/etc/init.d/mysql.server??
- #现在可以使用下面的命令启动mysql??
- service?mysql.server?start??
- #停止mysql服务??
- service?mysql.server?stop??
- #重启mysql服务??
- service?mysql.server?restart??
?
将mysql服务添加到开机启动项,让mysql服务开机启动
[c-sharp]?view plaincopy ?- chkconfig?--add?mysql
修改默认root账户密码,默认密码为空
修改密码 cd 切换到mysql所在目录?
cd /usr/local/mysql?
#./bin/mysqladmin -u root password?
回车在接下来的提示中设置新密码即可。。
?
? #启动MySQL
?? ?/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &
?? ?#或者
?? ?/etc/init.d/mysql start (service mysql start)
?? ? ?
?? ?#测试MySQL是否启动
?? ?# 1)查看是否有进程mysql
?? ?ps -ef | grep mysql
?? ?# 2)查看端口是否运行
?? ?netstat -tnl | grep 3306
?? ?# 3)读取mysql版本信息
?? ?mysqladmin version
?
转自:http://blog.csdn.net/zqtsx/article/details/9378703

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

AI Hentai Generator
Generate AI Hentai for free.

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

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.
