In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Install MySQL (UNIX) (transfer) [@ more@] original author: haio
Www.php.com.cn
You must execute the basic instructions to install the MySQL source package (an ununpacked tar file): become root, use the su command
$su
Change the path to the installation file directory. (use / tmp/download/)
# cd / tmp/download/
Expand the file with the following command.
# gunzip-d-c mysql-3.22.xx.tar.gz | tar xvf
Enter the new directory. This is created during the decompression process.
# cd mysql-3.22.xx
You can now run the "configure" directive for the MySQL server. You can specify a number of options when executing the configure command. Using configure-help can help you understand all the configuration options. Select-- prefix to specify the direct installation path. Configure will check your compiler and other things. If you find an error, you can check it by looking at config.cache.
# configure-prefix=/usr/local/mysql
After completing the Config, you can get the actual binaries by executing the following command.
# make
You are now ready to install all the binaries. Run the following instructions to install the binaries in the directory selected by configure-prefix.
# make install
After you install the binaries, you can create a mysql table that specifies permissions.
# scripts/mysql_install_db
# cd / usr/local/mysql/bin
#. / safe_mysqld &
#. / mysqladmin-u root password ew-password
Note: / usr/local/mysql is the path where you chose to install the MySQL server. You can also install it in other paths.
To ensure that MySQL works properly, you need to run some simple tests. If the output result: BINDIR = / usr/local/mysql/bin, it proves that MySQL is working properly. The value of BINDIR is related to the prefix option selected above.
# BINDIR/mysqlshow-p
+-+
| | Databases |
+-+
| | mysql |
+-+
Once you have installed MySQL, it will automatically generate two databases. One is used to manage user, host, and server database permissions. The other is the test database (test database). We can use the test database. However, we want to give you a quick and simple overview of some of the instructions that can be used in MySQL. This also ensures that root is set to have full access to the server, for example, root allows you to create databases, forms, etc. So we will create a test2 database for future testing. Before entering MySQL through the command, you will be prompted for the newly created root password. You should remember that you have changed root's password.
# mysql-u root-p
Mysql > show databases
+-+
| | Database |
+-+
| | mysql |
| | test |
+-+
Mysql > create database test2
Query OK, 1 row affected (0.00 sec)
Follow the following two pieces of code to choose to use the new database and create a table named tst_tbl, which has two fields. The first field (field 1) is the id field, through which you can see the id number of the record. In essence, this is just a list of pure numbers. The second field is the name field, where you can store the name of the book. The format of these fields is: field 1 (id) is an integer of length 3 (int), and field 2 (name) is a string of length 50 (char). Our assignment to id enables data lookup and indexing.
Mysql > use test2
Database changed
Mysql > CREATE TABLE books (id int (3) not null
-> auto_increment, name char (50) not null
-> unique (id), primary key (id)
Query OK, 0 rows affected (0.00 sec)
Now use the following command to check that the library is correct.
Mysql > show tables
+-+
| | Tables in test2 |
+-+
| | books |
+-+
1 row in set (0.00 sec)
Mysql > describe books
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | id | int (3) | | PRI | 0 | auto_increment |
| | name | char (50) |
+-+ +
2 rows in set (0.00 sec)
Note: the describe directive basically depicts the layout of the table. How cool!
OK, here are some really useful SQL instructions: how to insert and select data in a database. You can now add several records to the new table. Keep in mind that these are just simple records of book names, but when you have enough experience with SQL, you can build complex databases of large e-commerce sites. Let's create two imaginary book records. One record is the name of the book "PHP 4 Newbies" and the other is the name of Linux's next useful book, "Red Hat Linux 6 Server", written by Mohammed J. Kabir.
Mysql > INSERT INTO books (name) values (PHP 4 Newbies)
Query OK, 1 row affected (0.00 sec)
Mysql > INSERT INTO books (name) values (Red Hat Linux 6 Server)
Query OK, 1 row affected (0.00 sec)
Now check the new record and familiarize yourself with the select directive.
Mysql > SELECT * from books
+-+-
| | id | name |
+-+-
| | 1 | PHP for Newbies |
| | 2 | Red Hat Linux 6 Server |
+-+-
2 rows in set (0.00 sec)
In this way, the MySQL server can already run normally. We can continue to add records, but there is no more meaning here.
Note: when you insert records into the database, you do not have to specify id. This is because you have the option to automatically add the id field.
Here's how to quickly delete. This is just to give you a simple message, remember that you can find all the mysql instructions and server information you want at the mysql web site http://www.mysql.com.
Mysql > delete from books where id=1
Query OK, 1 row affected (0.00 sec)
Mysql > select * from books
+-+-
| | id | name |
+-+-
| | 2 | Red Hat Linux 6 Server |
+-+-
1 row in set (0.00 sec)
Ok, exit MySQL and proceed to the next step of installation. After all the installation is complete and everything is working properly, you can run MySQL
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.