Mysql noinstall installation tutorial (recommended)

Source: Internet
Author: User
Tags mysql commands

1. Software Download

Download the mysqldecompressed package from the official website of mysql, for example, mysql-noinstall-5.0.51b-win32.zip.

Then decompress it to a location where you want the database to be located, such as C :\

In this way in the C: disk has a directory such as C: \ mysql-5.0.51b-win32, which is all the content of the MySQL database.

2. Configuration

First, let's look at the MySQL root directory, which contains multiple file names, such as my -****. ini file. This is the sample MySQL configuration file. You can select one of them and change its name to my. ini. This is what MySQL reads when it starts. the INI file determines the database parameters.

In the my. ini file, you need to configure the client and server.

* Client Configuration

# CLIENT SECTION
#-----------------------------------------------------
[Client]
Port = 3306

[Mysql]
Default-character-set = gbk

There are two main items to be configured: one is the client port and the other is the default character set (gbk is set to Chinese). The default port 3306 is used here, character set can be changed to UTF-8 or GBK as needed.

* Server Configuration

# SERVER SECTION
#-----------------------------------------------------
[Mysqld]
Port = 3306

Basedir = "C:/mysql-5.0.51b-win32"

Datadir = "C:/mysql-5.0.51b-win32/Data"

Server = "c:/mysql-5.0.51b-win32/bin/mysqld-nt.exe"

Default-character-set = gbk

Default-storage-engine = INNODB

Max_connections = 100

Max_allowed_packet = 16 M

Here the main port is port, database installation directory (that is, the directory we extract) basedir, database data

Datadir.

The second is the character set setting and the setting of the maximum number of connections. The actual setting items should be based on the needs of development and use.

Test several sample files in the extracted directory for configuration selection.

3. Start the Mysql database

* You can add C: \ mysql-5.0.51b-win32 \ bin in the path of the Windows environment variable, so that we can directly use the mysql commands in the command line.

* In the command line window, run c: \ mysqld-nt. this is the Windows Task Manager. In the process, a mysqld-nt.exe is generated, indicating that the database has been successfully started.

* In addition, We can register a database as a service and start it as the system starts. The specific command is as follows:

C: \ mysqld-nt-install

After running the preceding command, a service named MySQL will be registered in the system service, and its starting nature is Automatic. By default, this service is automatically started.

You can use the command line to prevent the service from being stopped or started, for example:

C: \ net start MySQL startup)
C: \ net stop MySQL (stop)
C: \ mysqld-nt -- remove MySQL (uninstall service)

4. Use the MySQL database

* Because bin in the MySQL installation directory is added to the path of the environment variable, MySQL command can be directly used.

* After the above information is configured and MySQL is started, the default user name is root and the password is blank. Therefore, we can use the following command to log on to the database:
  
C: \ mysql-uroot-hlocalhost

After you press enter, the following command line status will be displayed:

Mysql>

This indicates that you have successfully logged on to the MySQL database.

If you want to add a password to the root user, you can exit mysql> quit and use the following command to set the password for the root user:

C: \ mysqladmin-uroot password 123456

In this way, the password of the root user is changed to 123456. The following code is required to log on to the database again:

C: \ mysql-uroot-p123456-hlocalhost

So far, the configuration of the MySQL5 database is complete. You can use the database through the client or program.

5. Summary

MySQL provides two methods for downloading and installing the Install and NotInstall file packages. the Install method is more intuitive and convenient, while the notInstall method allows you to better understand the basic configuration content of the MySQL database, therefore, they have their own advantages and disadvantages. From a personal perspective, we recommend the notIntall method to use the Mhysql database, which lays a good foundation for using MySQL on different platforms.

The following is a basic configuration file named my. ini.
######################################## ##############
# MySQL Server Instance Configuration File
######################################## ##############

# CLIENT SECTION
#-----------------------------------------------------
[Client]
Port = 3306

[Mysql]
Default-character-set = gbk

# SERVER SECTION
#-----------------------------------------------------
[Mysqld]
# The TCP/IP Port the MySQL Server will listen on
Port = 3306

# Path to installation directory
Basedir = "C:/mysql-5.0.51b-win32"

# Path to the database root
Datadir = "C:/mysql-5.0.51b-win32/Data"

# The default character set that will be used when a new schema or table is
# Created and no character set is defined
Default-character-set = gbk

# The default storage engine that will be used when create new tables when
Default-storage-engine = INNODB

# The maximum amount of concurrent sessions the MySQL server will
# Allow. One of these connections will be reserved for a user
# SUPER privileges to allow the administrator to login even if
# Connection limit has been reached.
Max_connections = 100

Max_allowed_packet = 16 M

################################# Boneguan

Apache installation-free is much simpler

Keep the installed installation directory
You do not need to install bin/httpd.exe-k install-n servicename (if apache2 Is In The apache2 series ..)
Mysql can do the same. Of course, jdk environment variables still need to be configured.
Mysql 5.1 noinstall manual configuration method

1. Configure Option File
Mysql5.1 installed with mysql install will automatically generate the configuration file "my. ini" or "my. conf". Unzip the file to complete the installation of mysql 5.1.
The profile my-huge.ini, my-innodb-heavy-4Gini, my-large.ini, my-medium.ini, my-small.ini, and profiles are provided under the root extract directory of mysql5.1. Choose one of them as my. INI file template file, create my. the INI file specifies the installation directory of your mysql 5.1. For example, if your mysql 5.1 is installed in the "D: \ mysql" directory. add the following configuration information to the INI file:
[Mysqld]
# Set basedir to your installation path
Basedir = D:/mysql
# Set datadir to the location of your data directory
Datadir = D:/mydata/data
2. Select the server running type
Mysql5.1 server supports the following startup methods:
Mysqld-debug: InnoDB and BDB tables are supported. The debug mode automatically checks the memory usage.
Mysqld: InnoDB tables is supported.
Mysqld-nt: supports Windows NT, 2000, and XP systems, and named pipes.
Mysqld-max: InnoDB and BDB tables are supported.
Mysqld-max-nt: supports InnoDB and BDB tables and named pipes
Mysqld-nt and mysqld-max-nt support "named pipes". However, the default system uses the TCP/IP method, and the named pipes method is slow to process.

The general system uses the server type of mysqld

3. Start the service
You can enter the mysql startup command in the command line:
% YOUR_MYSQL_PATH % \ bin \ mysqld
You can use "-- console" to view the system running status on the background management end.

Stop Service
% YOUR_MYSQL_PATH % \ bin \ mysqladmin-u root shutdown

You can put "% YOUR_MYSQL_PATH % \ bin" in your environment variable "path" to directly run mysql commands.
4. Start mysql as the system services
In windows, we recommend that you enable mysql as a system service. In this way, mysql is automatically disabled when the system is disabled.
Follow these steps to use mysql as the system services
Mysqld -- install MySQL -- defaults-file = C: \ my-opts.cnf
"MySQL" is the name of the system service.
If the "-- defaults-file" parameter is not provided, the system uses the mysql Default Configuration file for service configuration. You can also use this parameter to configure system services.

When running mysql services, you cannot see the system error information on the console. These error messages can be found in the "% YOUR_MYSQL_PATH \ data" directory. The file suffix is ". err"

When mysql is used as a system service, you can use the following command to start and stop the mysql service:
Start: net start mysql
Stop: net stop mysql

You can use the following command to install mysql services as a manually started service:
Mysqld -- install-manual

Remove mysql services, stop the service by using "net stop mysql", and then run the "mysqld -- remove" command to remove the service.
5. Test mysql Installation
Run the following command to check mysql installation:
Mysqlshow
Mysqlshow-u root mysql
Mysqladmin-u root version status proc
Mysql-u root test

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.