Mysql Chinese Reference Manual 5 (under MySQL)

zhaozj2021-02-11  235

MySQL Chinese Reference Manual 5 (under Mysql)

Translator: 子

Back to〗 Forward〗

Translator: Clyan@sohu.com) Home: http://linuxdb.yeah.net4.12 Win32 Notes This section describes the installation and use of MySQL on Win32, which is also "Readme" in MySQL Win32 distribution Description in the file. 4.12.1 Install MySQL on Win32 If you don't have a registered mysql version, you should first download the shared software version, from: mysql 3.21.29 If you are ready to connect to MySQL from some other programs, you may also need the MyodBC driver. You can find it in the MySQL download page. Install any distribution, decompress it in an empty directory and run the setup.exe program. By default, mysql-win32 is configured to be installed in "C: MySQL". If you want to install MySQL elsewhere, install it in C: MySQL, then move the installation to where you want. If you really remove MySQL, you must tell me everything in MySQLD by providing options, using c: mysqlinmysqld - Help Display all selected items! For example, if you move MySQL to "D: ProgramSmysql", you must use D: ProgramSmysqlinmysqld --BaseDir D: ProgramSMysql to start MySQLD. With registered MySQL versions, you can also create a "c: my.cnf" file to save any default options for the MySQL server. Copy file "mysqlmy-esample.cnf" to "c: my.cnf" and edit it to apply for your installation. Note that you should use "/" instead "to specify all the paths. If you use "", you need to specify twice (""), because in MySQL "" is a escape character, see 4.15.4 option file. 4.12.2 Start Mysqlmysql on Win95 / Win98 Use TCP / IP to connect a client to a server. (This will allow any machine to connect to your MySQL server on your network). Therefore, you must install TCP / IP on your machine before starting MySQL, you can find TCP / IP on your Windows CDROM. Note: If you are using an old Win95 version (such as OSR2), it is likely that you have an old Winsock package! MySQL requires Winsock 2! You can get the latest Winsock from Microsoft. Win98 has a new Winsock 2 library as a default, so that the above is not suitable for Win98. You can use 2 different mysql servers: MySQLD is assigned with full debugging and automatic memory to compile Mysqld-OPT optimized Pentium processor. The above two should work on any> = i386 Intel processor. In order to start the MySQLD server, you should start a MSDOS window and type: c: mysqlinmysqld This will start mysqld in a background without a window. You can kill the MySQL server, execute: c: mysqlinmysqladmin -u root shutdown Note that Win95 / Win98 does not support the creation of named pipes. On Win95 / Win98, you can only use the named pipe connection to run remote mysql on a NT server. 4.12.3 Starting the mysqlwin95 / win98 section on NT also applies to MySQL on NT, with the following difference: In order to be MySQL with TCP / IP, you must install the service package 3 (Service Pack 3) (or update)! For NT, the server name is MySQLD-NT.

Usually you should install MySQL on NT as a service: c: mysqlinmysqld-nt --install (you can use the MySQLD or MySQLD-OPT server on NT, but those that cannot be started or named as a service.) You You can start and stop using the following command: Net Start MySQLNET Stop MySQL Note In this case, you cannot use any other options for MySQLD-NT! If you need to start mysqld-nt with any option, you can also act as NT A separate program runs mysqld-nt! If you don't have an option on NT to launch mysqld-nt, MySQLD-NT tries to launch yourself as a service with the default option. If you stop MySQLD-NT, you must start with Net Start MySQL. The service is installed with a MySQL name. Once installed, it must start the service using the Service Control Manager (SCM) utility (found in the control panel) or use the NET Start MySQL command. If you need any options, you must specify them as a "startup parameter" of the SCM utility before you start MySQL service. Once run, use mysqladmin or stop mysqld-nt from the SCM utility or using the command NET STOP MYSQL. If you use SCM to stop MySQLD-NT, SCM has a strange message about MySQLD Shutdown Normally. When as a service run, MySQLD-NT has no console access permission, so there is no message to see. On NT you can get the following service error message: Permission Denied (permission refusal) means it can't find mysqld-nt.exe cannot register (can not register) means that the path is incorrect if you install mysqld-nt as a service There is a problem, try to start it with a complete path: c: mysqlinmysqld --install If this still doesn't work, you can make MySQLD-NT to start correctly by the registry correcting the path! If you don't want to start MySQLD-NT as a service, you can start it: c: mysqlinmysqld-nt --standalone or c: MySQLINMYSQLD-NT --STANDALONE - DEBUG latest version in "c: mysqld.trace" You a debugray. 4.12.4 Running mysqlmysql on Win32 supports TCP / IP and NT naming pipes on all Win32 platforms. If the customer has installed TCP / IP, the default is to use a nammon connection to the NT to use TCP / IP for all other situations. Which protocol is used for hostname: Host Name Protocol (no) on NT, first try Named pipe; if it doesn't work, use TCP / IP. On Win95 / Win98, TCP / IP is used. Named pipe localhost TCP / IP to the current host hostname TCP / IP You can force a MySQL customer to use a named pipe by specifying a naming pipeline -PIPE option. Use the - Socket option to specify the name of the pipe. By performing the following command, you can test if mysql is working: c: mysqlinmysqlshowc: mysqlinmysqlshowc: mysqlinmysqlshowc: mysqlc: mysqlinmysqladmin version status procc: MySQLINMYSQL TEST If you answer the connection slowly on Win95 / Win98, you may have problems with your DNS.

In this case, start MySQLD with - Skip-name-resolve and use only localHost and IP numbers in the MySQL license table. When you are connected to a MySQL server on NT on NT, use -pipe Specifies the parameters used by named pipes, you can also avoid DNS, which is feasible to most MySQL customers. There are 2 versions of MySQL command line tools: MySQL compile with native Win32, which provides very limited text editing capabilities. MySQLC compiles with Cygnus GNU compiler and library, which provides Readline editing. If you want to use mysqlc.exe, you must copy "c: mysqllibcygwinb19.dll" to "Windowssystem" (or similar place). Default permissions on Win32 Give all local users with full permissions of all databases. In order to make MySQL more secure, you should set your password for each user and remove the rows of Host = 'localhost' and user = '' in mysql.user. You should also add a password for root users: (The following example allows anyone to access "test" database) C: mysqlinmysql mysqlmysql> delete from user where host = 'localhost' and user = '; mysql> Quitc: MySQLINMYSQLADMIN RETP: MySQLINMYSQLADMIN -U ROOT Password Your_password After you set your password, if you want to turn off the MySQLD server, you can use this command: mysqladmin - user = root - password = Your_password shutdown If you are Using the MySQL shared software version under Windows, the above command will fail with Parse Error Near 'Set Option Password', because this is a shared software version, which is based on MySQL 3.21, no set password command. For the shared software version, you can set the root user password as follows: c: mysqlinmysql mysqlmysql> update user set password = password ('Your password') where user = 'root'; mysql> quitc: mysqlinmysqladmin reload has registered mysql version, you You can easily add new users and change permissions with Grant and Revoke commands, see 7.26 GRANT and REVOKE syntax. For Windows shared software versions, you must use INSERT, UPDATE, and DELETE in a table in the MySQL database to manage users and their permissions, see 6.13 Accept Denied error reasons. 4.12.5 Connecting a remote mysql from Win32 This is a precautions for how to get a secure connection remote mysql server with SSH (David Carlson).

Install SSH Customers on your Windows machine - I used a free SSH customer from http://www.doc.ic.ac.uk/~ci2/ssh/. Other useful links: http://www.npaci.edu/security/npaci_security_software.html and http://www.npaci.edu/security/samples/ssh32_windows/index.html. Start SSH. Set the host name = Your MySQL server name or IP address, set userid = your username is logged to your server. Click "Local ForWords". Set Local Port: 3306, Host: Localhost, Remote Port: 3306 Save everything, otherwise you will have to do it again. Log in to your server with SSH. Start some ODBC applications (such as Access). Create a new file and contact Mysql with an ODBC driver, just like you usually do, in addition to user "localhost" for the server. Get it. It works very well on a direct Internet connection. I have some problems, SSH has conflicts with my Win95 network and Wingate - but that will be the topic of the user group posted in other software companies! 4.12.6 MySQL-Win32 and UNIX MySQL Comparison MySQL-Win32 has now proved that they are stable. This version has the same feature as the corresponding UNIX version, except: Win95 and thread win95 for each thread's creation of about 200 bytes of memory. So if you do a lot of connections, you should not run mysqld in Win95 for a long time, because each connection of MySQL creates a new thread! Winnt and Win98 cannot tolerate this bug. Blocking read MySQL uses a blocking reading for each connection, which means that a connection will be automatically disconnected after 8 hours, just like MySQL UNIX version. If a connection "hangs", it is impossible to break it if you don't kill MySQL. MySQLADMIN KILL will not work on a sleep connection. As long as there is a connection to sleep, mysqladmin shutdown cannot be interrupted in the middle. We plan to fix it in the near future. UDF functions temporary mysql-win32 does not support user-definable functions. DROP DATABASE You cannot abandon a database that is being used by some threads. Kill MySQL from the task manager on Windows 95, you cannot kill mysql from the task manager or with the shutdown utility. You must close it with mysqladmin shutdown. The name file name file name is ignored on Win32, so the name of MySQL database and table on Win32 is also ignored. The only restriction is the name of the database and table must be the same in the entirety statement, because it uses my_table and my_table all to the same table, the following query will not work: select * from my_table where my_table. COL = 1; "" "Directory Character The path name on Win95 is separated by" "characters, which is also an escape character in MySQL.

If you are using Load Data Infile or Select ... INTO OUTFILE, you must use two "" characters or using UNIX style "/" characters: load data infile "c: mpskr.txt" INTO TABLE SKR; SELECT * From SKR INTO OUTFILE 'C: /TMP/skr.txt'; can't open named PIPE error If you use the MySQL-Win32 shared software version on NT, you will get the following error with the latest mysql customers: Error 2017 : Can't open named pipe to host:. Pipe ... This is because the official version of MySQL on NT default uses a nomencanement. You can avoid this error by using the "c: my.cnf" for the new MySQL customers or creates a file "c: my.cnf" containing the following information: [Client] host = localhostaccess Denied for User error is on the same machine When a mysql server, if you get an error of Access Denied for User: 'some-user @ unknown' to Database 'MySQL', this means that mysql can't correctly explain your host name. To correct it, you should create a file "WindowsHosts", with the following information: 127.0.0.1 Localhost For anyone who might want to help us do a good Win32 version, some open questions: Making a single user mysql.dll server. This should include everything in a standard mysql server, except for threads. This will make MySQL more easily when there is no need for a real client / server and does not need to access the server from other host access servers. Add some beautiful "start" and "shutdown" icons for MySQL. Creating a tool management registry entry for the MySQL startup option. Registry entries have been encoded into mysqld.cc, but it should be re-encoded and more "parameters", which should also update "My.cnf" files, if users prefer to use it rather than registry. When using -install registered mysqld as a service (on NT), if you can also add the default option on the command line, it will be better, the current solution is to update the "C: My.cnf" file. When you hang a laptop computer running Win95, the MySQLD daemon does not accept new connections when the laptop is recovered. We don't know if this is Win95, TCP / IP or MySQL issues. Can kill mysqld from the task manager will definitely be a good thing. Currently, you must use mysqladmin shutdown. Transplanting Readline to Win32 in the mysql command line tool. Standard GUI version mysql customers (mysql, mysqlshow, mysqladmin, and mysqldump) will be better. If the socket "Read" and "Write" function in "Net.c" are interrupted, it will be better. This will be possible to kill the open thread with MySQLADMIN KILL on Win32. Making which Windows programs work in mysql-win32 / myodbc and what must be done to make them work. MySQLD is always started at "C" instead of default, we want mysqld to use the current location for sorting order. Transplant SqlClient to Win32 (almost completed) and add more features! Add more options to MySQL Manager. Change the communication protocol between servers and customers, using Windows internal communications instead of sockets and TCP / IP. Use .dll to implement UDF functions.

Increase macros to use the faster addition / reduction method for thread security provided by Win32. Other Win32 specific issues are described in the "Readme" file distributed by MySQL-Win32. 4.13 OS / 2 Note Mysql Use too much open file. Therefore, you should add something like the following to your "config.sys" file: set emxopt = -c -n -h1024 If you don't do this, you will might touch the following error: file 'xxxx' Not found (Errcode : 24) When using MySQL on OS / 2 WARP 3, fixpack 29 or above is required. With OS / 2 WRAP 4, it is required to request FixPack 4 or more. This is a request for the PThreads library. MySQL must be installed on a partition that supports long file names, such as HPFS, FAT32, and more. "Install.cmd" script must run from OS / 2 '"cmd.exe" and cannot work in alternatives such as "4os2.exe". "Scripts / MySQL-Install-DB" script has been rentered: It is now called "install.cmd" and is a REXX handwriting, which will install the default MySQL security configuration and create a Workplace Shell icon for MySQL. The dynamic module supports compiling but not fully tested, the dynamic module should compile using the PTHReads runtime library. GCC -ZDLL -ZMT -ZCRTDLL = PTHRDRTL -I ../ include -i ../ regex -i .. -o example udf_example.ccc -l ../ lib -lmysqlclient udf_example.defmv Example.dll Example.uda Note: Due to the limitations of OS / 2, the name of the UDF module name cannot exceed 8 characters. The module is stored in the "/ mysql2 / udf" directory; the Safe-MySqld.cmd script will put this directory in the BeginLibPath environment variable. When using a UDF module, the specified extension is ignored - it is assumed to ".udf". For example, on UNIX, the shared module may be named "eXample.so" and you can load functions from it from it: create function metaphon returns string Soname "example.so"; os / 2, module will be named "EXample.udf", but you don't specify the module extension: create function metaphon return SONAME "example"; 4.14 TCX binary code as a service, TCX provides a set of mysql binary distribution, it is in TCX or friendly Compiled on the site that visits our machine's permissions.

These distributions are generated with scripts / make_binary_distribution and configure them with the following compilers and options: Sunos 4.1.4 2 Sun4c with GCC 2.7.2.1 cc = GCC CXX = GCC CXXFLAGS = -O3 ./configure --PREFIX = / usr / local / mysql --Disable-shared sunos 5.5.1 Sun4u with egcs 1.0.3a cc = gcc cflags = "- O6 -FOMIT-FRAME-POINTER" CXX = GCC CXXFLAGS = "- O6 -FOMIT-frame-Pointer -felide-Constructionors -fno -EXCEPTIONS -FNO-RTTI "./configure --prefix = / usr / local / mysql --with-low-memory sunos 5.6 Sun4u with egcs 2.90.27 cc = gcc cflags =" - o6 -Fomit-frame-pointer " CXX = GCC CXXFLAGS = "- O6 -FOMIT-FRAME-POINTER -FELIDE-Constructors -fno-Exceptions -fno-RTTI" ./configure --prefix = / usr / local / mysql --with-low-memory sunos 5.6 i86PC WITH GCC 2.8.1 CC = GCC CXX = GCC CXXFLAGS = -O3 ./configure --prefix = / usr / local / mysql --with-low-memory linux 2.0.33 i386 with pgcc 2.90.29 (EGCS 1.0.3A ) Cflags = "- O6 -MPENTIUM -MSTACK-ALIGN-DOUBLE -FOMIT-FRAME-POINTER" CXX = GCC CXXFLAGS = "- O6 -MPENTIUM -MSTACK-align-double -fomit-frame-point -felide-constructors -fno- Exceptions -fno-rtti "./configure --prefix = / usr / loc Al / mysql --enable-assembler --with-mysqld-ldflags = -all-static sco 3.2V5.0.4 i386 with GCC 2.7-95Q4 cc = GCC CXX = GCC cxxflags = -O3 ./configure --PREfix = / usr / local / mysql AIX 2 4 with GCC 2.7.2.2 CC = GCC CXX = GCC CXXFLAGS = -O3 ./configure --prefix = / usr / local / mysql OSF1 V4.0 564 Alpha with GCC 2.8.1 CC = GCC CFLAGS = -O CXX = GCC cxxflags = -O3 ./configure --prefix = / usr / local / mysql --with-low-memory Irix 6.3 IP32 with GCC 2.8.0 CC = GCC CXX = GCC CXXFLAGS = -O3 ./ Configure --prefix = / usr / local / mysql BSDI BSD / OS 3.1 i386 with GCC 2.7.2.1 cc =

GCC CXX = GCC CXXFLAGS = -O ./configure --prefix = / usr / local / mysql BSDI BSD / OS 2.1 i386 with GCC 2.7.2 CC = GCC CXX = GCC CXXFLAGS = -O3 ./configure --prefix = / USR / local / mysql can always send them to the developer mailing list than the above-described configuration options. MySQL3.22 previous RPM distribution is the user's contribution, since 3.22, some RPM is generated by TCX. 4.15 Installation and Test Once you have already installed mysql (from a binary code or source code distribution), you need to initialize the license table, start the server and ensure that the server is operating correctly. You can also want to arrange the server to automatically start and stop when your system is turned on and turned off. Typically, install the distribution from the source code, so you like to install the grant tables and start the server: shell> ./scripts/mysql_install_dbshell> cd mysql_installation_directoryshell> ./bin/safe_mysqld & For a binary distribution, do this: shell> cd mysql_installation_directoryshell>. / bin / mysql_install_dbshell> ./bin/safe_mysqld & Test The top-level directory issued in MySQL is the easiest. Different binary distribution, this is your installation directory (typically similar "/ usr / local / mysql"). Distribute to source code, this is the home directory of your MySQL source tree. In this section and later, in the following command, bindir is the path to the program such as mysqladmin and safe_mysqld installed. Binary distribution is the "bin" directory within the distribution. Distributing source code, Bindir may be "/ usr / local / bin" unless you specify an installation directory other than "/ usr / local" when you run configure. Execdir is the location where the mysqld server is installed, which is distributed to binary, which is the same as Bindir. Distribute to source code, Execdir may be "/ usr / local / libexec". Test details in the following description: If necessary, start the MySQLD server and establish an initial MySQL authorization table, which contains the permissions that determine how the user is allowed to connect to the server. This usually dos with mysql_install_db scripts: shell> scripts / mysql_install_db typically, mysql_install_db needs to run when you first install MySQL, so if you are upgrading an existing installation, you can skip this step. (However, the use of mysql_install_db is quite safe, and will not update any table already existing, so if you can't do anything, you can always run mysql_install_db.) Mysql_install_db created 6 tables in MySQL database (User, DB, Host, Tables_PRIV, COLUMNS_PRIV and FUNC), the description of the initial permissions is given in the 6.10 setting initial mysql permission. Simply put, these permissions allow mysql root users to do anything, and allow anyone to create or use a name that is started with 'Test' or 'Test_'.

If you don't set a permission table, when you start the server, the following errors will appear in the log file: mysqld: can't find file: 'host.frm' If you are not executed clearly ./bin/safe_mysqld to launch MySQL, The above error may also occur in MySQL binary code distribution! You may need to run mysql_install_db as root, however, if you like, if users can read and write files in the database directory, you can run the MySQL server as a non-privileged (non-ROOT) user. An instruction that runs Mysql as a non-privileged user is given in 18.8 as a general user runs Mysql. If you have a problem with mysql_install_db, see the problem of running mysql_install_db 4.15.1. Because MySQL_INSTALL_DB is released in MySQL, there are other ways to run it: you might want to edit it before running mysql_install_db, changing the initial permissions installed into the license table. This is useful if you want MYSQL installed in many machines with the same permissions. In this case, you may only need to add a few additional INSERT statements to mysql.user and mysql.db tables! If you want to change what you have after the installation authorization form, you can run mysql_install_db, then use mysql -u root mysql as a MySQL root user connection authorization table, issue SQL statements to directly modify the license table. Once a licensing form has been created, it may be created again. If you have already installed a table but then you want to create again after editing mySQL_INSTALL_DB, you may want to do this. For more information on these options, see 6.10 Establish initial MySQL permissions. Like the mysql server: shell> cd mysql_installation_directoryshell> BIN / SAFE_MYSQLD & If you start the server's question, see the problem of launching the MySQL server. Using the MySQLADMIN confirmed that the server is running. The following command provides a simple test to check the server startup and connection response: shell> bindir / mysqladmin version shell> bindir / mysqladmin variables from MySQLADMIN version of the output is slightly different according to your platform and MySQL version, but should look like this: shell > BINDIR / mysqladmin versionmysqladmin Ver 6.3 Distrib 3.22.9-beta, for pc-linux-gnu on i686TCX Datakonsult AB, by MontyServer version 3.22.9-betaProtocol version 10Connection Localhost via UNIX socketTCP port 3306UNIX socket /tmp/mysql.sockUptime: 16 SECRUNING THREADS: 1 Questions: 20 Reloads: 2 Open Tables: 3 In order to feel that you can do other things with bindir / mysqladmin, call it with --help options. Confirm that you can turn off the server: Shell> bindir / mysqladmin -u root shutdown confirms that you can restart the server.

Use SAFE_MYSQLD or directly call mysqld, for example: shell> Bindir / Safe_Mysqld --Log & If Safe_Mysqld fails, try running it from MySQL installation directory (if you are already there). If you still don't work, see the problem of starting the MySQL server if you still don't work. Run some simple test confirm that the server is working. The output should be similar to the following: shell> bindir / mysqlshow ----------- | Databases | ---------- | MySQL | ---- ------- Shell> Bindir / MySQLSHOW MYSQLDATABASE: MYSQL -------------- | Tables | -------------- | Columns_priv || DB || Func || Host || Tables_PRIV || User | -------------- Shell> Bindir / MySQL -E "SELECT HOST, DB, USER" "MySQL ------ -------- ---- | Host | DB | User | ------ -------- - ----- |% | TEST | ||% | Test_% | | ------ -------- ------ in the "SQL-Bench" directory (In the MySQL installation directory), there is a reference test suite, which you can use to compare how Mysql performance on different platforms. The "SQL-Bench / Results" directory contains many run results for different databases and platforms. In order to run all the tests, execute these commands: shell> CD SQL-Benchshell> Run-all-tests If you don't have a "SQL-Bench" directory, you may use an RPM in binary distribution (source code distribution RPM including the reference directory ). In this case, you must first install the baseline kit before you can use it. Starting from MySQL 3.22, a reference RPM package called "MySQL-Bench-Version-I386.rpm", which contains a baseline code and data. If you have source code distribution, you can also run the test in the "Tests" subdirectory. For example, run "auto_increment.tst", do this: shell> bindir / mysql -vvf test <./tests/auto_increment.tst The desired result is displayed in the "./tests/auto_increment.res" file. 4.15.1 Running MySQL_INSTALL_DB This section is listed in this section. When you run mysql_install_db, you may meet questions: mysql_install_db does not install the license list After displaying the following message, you can find mysql_install_db can't install a license form and terminate: Starting MySQLD DAEMON with DATABASESSESSESES From xxxxxxmysql daemon ended In this case, you should carefully verify the log file! The log file should be located in the directory "xxxxxx", named the error message, and should point out why mySQLD is not started.

If you don't understand what happened, when you mail an error report using mysqlbug! See 2.3 How to report errors or problems. There is already a MySQLD daemon running in this case, you may not have to run mysql_install_db at all. When you first install MySQL, you must only run mysql_install_db once. When a daemon is running, install the second mysqld daemon does not work. This is only when you already have an existing MySQL installation but you want to put a new installation in a different place (for example, for testing Or maybe you simply want to run 2 installations at the same time. Usually when you try to run a second server, the problem that happens is that it tries and the old one to use the same socket and port ã. In this case, you will get an error message: can't Start Server: Bind on TCP / IP Port: address already in use or can't Start Server: Bind on unix socket ... you can use a different set Sockets port and start a new server as follows: shell> MYSQL_UNIX_PORT = / tmp / mysqld-new.sockshell> MYSQL_TCP_PORT = 3307shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORTshell> scripts / mysql_install_dbshell> bin / safe_mysqld & after this, you should edit your server The boot script handwritten with different sockets and ports to launch two daemons. For example, it can call SAFE_MYSQLD twice, but use different-Socket, - port, and -basedir options each time. You don't have a write permission for "/ TMP" if you don't write permission to create a socket file in the default place (in "/ tmp"), or if you don't have a temporary file in "/ TMP", run mysql_install_db or You will get an error when you start or use mysqld. You can specify a different socket and temporary directory as follows: Shell> TmpDir = / Some_tmp_dir / shell> mysql_unix_port = / some_tmp_dir / mysqld.sock shell> Export tmpdir mySQL_UNIX_PORT "Some_TMP_DIR" should be a directory you have written permit path of. Subsequent, you should run mysql_install_db and these command launch servers: shell> scripts / mysql_install_dbshell> Bindir / Safe_Mysqld & mysqld immediately crash if you are running RedHat 5.0, there is a 2.0.7-5 glibc version, you should guarantee You have installed all GLIBC! There are a lot of information about it in the MySQL mail file. The link of the Mail file can be obtained online at the online mysql document page. It is also possible to see 4.11.5 Linux Precautions (all Linux versions). You can also start mysqld, using the --skip-grant option and add permission information using MySQL itself: shell> bindir / safe_mysqld --skip-grant & shell> bindir / mysql -u root mysql from mysql, manually executed in MySQL_INSTALL_DB SQL command. Make sure you follow the mysqladmin reload to tell the server to load the authorization table.

4.15.2 Starting the Mysql Server Usually, you launch the MySQLD server with one of the 3 methods: By calling mysql.server. This script is mainly used for system launch and closing, and more comprehensive descriptions are automatically started and stop MySQL automatically in 4.15.3. By calling Safe_Mysqld, it tries to determine the correct option for mysqld and then run it with those options. Call mysqld directly. No matter which method you use, start the server, if it does not start correctly, check the log file to see if you can find why. The log file is located in the data directory (for binary distribution is generally "/ usr / local / mysql / data", and the source code distribution is "/ usr / local / var"). Use "Host_Name.err" and "Host_Name.log" form to find files in the data directory, here Host_name is the name of your server host, then check the last few lines of these files: Shell> Tail Host_name.errshell> Tail Host_name. LOG When the mysqld daemon starts, it changes the directory to the data directory. This is where it looks like to write log files and PIDs files, and it expects to find the database there. The data directory location is dead when it is distributed. However, if mysqld expects it to find the data directory in your system, it will work abnormally. If you have an incorrect path issue, you can use the --help option to call mysqld, find what the mysqld allows what options and the default path settings. You can override the default value by specifying the correct path as a MySQLD command line parameter. (These options can also be used for SAFE_MYSQLD.) Usually you should only tell the mysqld base directory, install MySQL below it. You can use the --basedir option, you can use -Help to check the effect of changing the path option (note that - Help must be the last option of the mysqld command). For example: shell> execdir / mysqld --BaseDir = / usr / local --help Once you make sure the path settings you want, do not use the --help option to start the server. If you get the following errors, it means that mysqld is trying to use some other programs (or other MySQLD servers) already being using TCP / IP ports or sockets: Can't Start Server: Bind on TCP / IP Port: Address Already IN Use or Can't Start Server: Bind on Unix Socket ... Using PS to ensure that you don't have another MySQLD server is running. If you can't find other running servers, you can try the telnet your-host-name tcp-ip-port-number and press several returni, if you don't get an error message, like telnet: unable to connect to recote Host: Connection Refused, a thing is using MySQLD TCP / IP port that is trying to use, see the problem of running mysql_install_db and 19.3 running multiple MySQL servers on the same machine. The SAFE_MYSQLD script is written in order to start a server installed from the MySQL source or binary code version, even if these are installing the server at a slightly different location. SAFE_MYSQLD hopes that one of these conditions is true: the server and database can be found in the directory relative to SAFE_MYSQLD. SAFE_MYSQLD is found under its working directory ("Data" directory (binary distribution) or "libexec" and "var" directory (for source code distribution).

If you execute Safe_Mysqld from your MySQL installation directory (for example, distributing binary into "/ usr / local / mysql"), this condition should be met. If the server and database cannot be found relative to its working directory, SAFE_MYSQLD tries to find them through the absolute path. Typical locations are "/ usr / local / libexec" and "/ usr / local / var". The actual location is determined when constructing SAFE_MYSQLD from distribution, if mysql is installed in a standard location, they should be correct. Because SAFE_MYSQLD will try to find the server and database in the relative to its own working directory, you can install the mysql binary distribution anywhere, as long as you start SAFE_MYSQLD from the MySQL installation directory: Shell> cd mysql_installation_directoryshell> bin / safe_mysqld & if Safe_Mysqld & if Failure, even when calling from the MySQL installation directory, you can modify it to use the MySQLD path and the path options for your system are correct. Note that if you upgrade MySQL in the future, your SAFE_MYSQLD modified version will be overwritten, so you should be a copy of the edited version you can reinstall. If mysqld is currently running, by performing this command, you can find what path settings it is using: Shell> mysqladmin variables or shell> mysqladmin -h 'your-host-name' If the SAFE_MYSQLD starts the server but you can't connect to it, You should guarantee that you have an entry in "/ etc / hosts", look like this: 127.0.0.1 localhost This problem only occurs on the system where there is no working thread library and must be configured to use MIT -pthreads. 4.15.3 Automatically start and stop MySQLMYSQL.Server script can be used to start or stop the server, call it with start or stop parameters: shell> mysql.server startshell> mysql.server stopmysql.server can be in MySQL installation directory " The share / mysql directory is found, or found in the "Support-Files" directory of the MySQL source tree. Before the mysql.server launches the server, it changes the directory to the MySQL installation directory and then calls Safe_Mysqld. If you have binary distribution installed in a non-standard location, you may need to edit mysql.server. Modify it, before running SAFE_MYSQLD, CD to the correct directory. If you want to run the server as some specific users, you can change the mysql_daemon_user = root, you can modify mysql.server to pass the other options to Safe_Mysqld. MySQL.Server STOP stops it by emitting a signal to the server. You can manually execute mysqladmin shutdown shut down the server. When you start using MySQL as a production application, you may want to add these boots and stop commands to your "appropriate place in your" / etc / rc * file. Note If you modify mysql.server, then if you When upgrading MySQL, your modified version will be overwritten, so you should be a copy of the edited version you can reinstall.

If your system uses "/etc/rc.local" to boot external script, you should add the following: / bin / sh -c 'cd / usr / local / mysql; ./bin/safe_mysqld &' you can also An option to add mysql.server in a global "/etc/my.cnf" file. A typical "/etc/my.cnf" file may look like this: mysqld] datadir = / usr / local / mysql / varsocket = / tmp / mysqld.sockport = 3306 [mysql.server] user = mysqlbasedir = / usr /local/mysqlmysql.server script uses the following variables: User, DataDir, Basedir, Bindir and Pid-file. See 4.15.4 Options file. 4.15.4 Options file MySQL3.22 You can read the default startup options for the server and customers from the options file. On UNIX, MySQL reads the default selection from the following file: File name /etc/my.cnf Global Options DATADIR / MY.CNF server-specific selection item ~ / .my.cnf user-specific option dataDir is mysql data Directory (typically a binary installation is "/ usr / local / mysql / data" or the source code installation is "/ usr / local / var"). Note: This is the directory specified by the configuration time, not the directory specified by -DATADIR when MySQLD is started! (--DATADIR is invalid if the server is looking for options files because it previously looking for them, it handles any command line parameters.) MySQL reads the default option from the following files on Win32: File name Windows-System-DirectorymyMy.ini C: my.cnf global option C: MySQLDATAMY.CNF server-specific options Note, you should use / not specify all paths in Win32, if you use, you need to specify two, because in MySQL is a escape character . MySQL attempts to read options files in the order listed above. If there are multiple options files, the options read in a back file preferred to the same option specified in the previously read file, and the options specified on the command line take the options specified in any option file. Some options can be specified using environment variables, at the command line or the option specified by the Options priority to the environment variable. The following programs support options file: mysql, mysqladmin, mysqld, mysqldump, mysqlimport, mysql.server, myisamchk, and myisampack. You can use the options file to specify any long options supported by a program! Use the -help option to run the list of available options available. One option file can contain the following forms: #comment Tetrane Start with "#" or ";", the blank line is ignored. [Group] Group is the name of the program or group you want to set options for it. After a group, any Option or SET-VARIABL line is applied to the named group until the file ends or other groups are selected. Option This is equivalent to on the command line. Option = value This is equivalent to --Option = Value on the command line. Set-variable = variable = value This is equivalent to -set-variable variable = value on the command line. This syntax must be used to set a MySQLD variable. The Client group allows you to specify options that apply to all MySQL customers (not mysqld). This is the ideal group to specify the password you use to connect to the server. (But guarantees that only the option file itself is readable and writable.

Note that all heads and tail blank are automatically deleted for domain options and values. You can use escape order ",", ",", ",", "," s "(" s "== blank). This is a typical global option file: [client] port = 3306 socket = / tmp / mysql.sock [mysqld] port = 3306 socket = / tmp / mysql.sock set-variable = key_buffer = 16m set-variable = max_allowed_packet = 1M [mysqldump] Quick This is a typical user options file: [Client] # The following password Will Be Sent to all standard mysql clientsword = my_password [mysql] no-auto-rehash If you have a source code distribution, you will be " A SUPPORT-Files catalog found a sample configuration file called "My-Example.cnf" sample. If you have binary distribution, look for the "DIR / Share / MySQL" directory, where DIR is the path to the mysql installation directory (generally "/ usr / local / mysql"). You can copy "My-Example.cnf" to your home directory (rename the copy to ".my.cnf") to test. In order to tell a mysql program, do not read any option file, specify -no-defaults on the command line as the first option. This must be the first option, otherwise it will be invalid! If you want to check which option to use, you can give theprint-defaults option as the first option. If you want to force to use a specific configuration file, you can use the option --defaults-file = full-path-to-default-file. If you do this, only the specified file will be read. Developer Note: The processing of the option file simply implements all the matching options pre-any command line parameters (ie, in the appropriate group option), this for the last instance of one option specified multiple times Work is very good. If you have such an old program that handles multiple specified options but not reading the option file, you only need to add 2 lines to it. Check what to do in the source code of any standard mysql customer. 4.16 Is there any special thing when upgrading / downgrade mysql? As long as you have the foundation version of MySQL, you can always move the MySQL table (FORM) and data files between different versions of the same architecture. The current foundation is 3. If you change the character set by recompiling MySQL (you can also change the sort order), you must run myisamchk -r -q on all tables, otherwise your index cannot be properly sorted. If you are paranoid or worried about new version, you can rename the old MySQLD to mysqld-version-number '. So if your new MySQLD does something unexpected, you can simply turn off it and restart your old mysqld! When you make an upgrade, of course, you should also back up your old database. Sometimes a little biased is good! After upgrading, if you recompile the client, you can use an old header file or library file when you compile your program when you recompile the client, like Commands Out of Sync or an unexpected core. In this case, you should check your "mysql.h" file and "libmysqlclient.a" dates to confirm that they are from new MySQL issuance.

If not, please recompile your program! If you have some problems, the new MySQLD server doesn't want to start or you can't connect without a password, check that you don't have some old "my.cnf" files from your old installation! You can check with program-name --Print-defaults. If this outputs anything of any non-program name, you have an active my.cnf file that will affect some things! Whenever you install a new version of MySQL, rebound and reinstall MSQL-mysql-modules distribution is a good idea, especially after upgrading MySQL, if you pay attention to all of your DBI script dumping core symptoms. 4.16.1 Upgrade from a 3.22 version to 3.23mysql 3.23 supports a new Myisam type and an old ISAM type table. You don't have to transform your old forms to use 3.23. By default, all new tables will be created with type Myisam (unless you use the --default-Table-Type = ISAM option to start mysqld). You can use ALTER TABLE or Perl script mysql_convert_table_format to convert an ISAM table into a Myisa table. 3.22 and 3.21 Customers will work with a 3.23 server without any problem. When upgrading to 3.23, the following is listed below: Inner and Delayed are now reserved. Float (x) is now a true floating point type. When Decimal (Length, DEC) is declared, the length parameter no longer includes a symbol or decimal point position. A Time string must be one of the following existing formats: [[DAYS] [H] h:] mm:] ss [.fraction] or [[[[h] h] h] h] mm] ss [ .fraction]. Now, Like uses '=' The same characters compare rules compare strings. If you asked the old behavior, you can use the cxxflags = -dlike_cmp_toupper flag to compile MYSQL. Regexp is now neglecting for normal (not binary) strings. When you check / fix the table, you should use MyisamCHK when you check / fix the table, and use ISAMCHK. If you want your mysqldumps compatible between MySQL3.22 and 3.23, you should not use mysqldump --opt or --full options. Check all the call to DATE_FORMAT () to ensure that there is a "%" in front of each format character. MySQL_FETCH_FIELDS_DIRECT is now a function (it is previously a macro) and it returns a pointer to my mysql_field instead of a mysql_field. MySQL_NUM_FIELDS () can no longer be used on a mysql * object (it is now a function, take mySQL_RES * as a parameter). On the contrary, you should now use mysql_field_count (). In mysql3.22, the output of Select Distinct ... is almost always sorted. On 3.23, you must use Group By or Order By to get sorted output. If there is no match, sum () now returns NULL instead of 0. This is followed by ANSI SQL. New restrictions: Case, THEN, WHEN, ELSE and END. 4.16.2 Upgrading from a 3.21 version to 3.22 There is no effect on compatibility between 3.21 and 3.22. The only drawback is a new table created with a Date class type will use a new method to store the date. You can't access these new fields from an old version of MySQLD. After installing MySQL3.22, you should start a new server and then run the mysql_fix_privilege_tables script. This will increase the new permissions you need to use the grant command.

If you have forgotten this, you will get Access Denied when you try to use ALTER TABLE, CREATE INDEX or DROP INDEX. If your MySQL root user requires a password, you should use it as a parameter to mysql_fix_privilege_tables. The C API interface of mysql_real_connect () changed. If you have an old client call to call this function, you must put a 0 as a new DB parameter (or customers who quickly connect to re-encoding the DB unit). You must call mysql_init () before mysql_real_connect ()! Do this change allows the new mysql_options () function to save options in the MySQL handler structure. 4.16.3 Upgrade from a 3.20 version to 3.21 If you are running a 3.20.21 old version and you want to change to 3.21.x, you need to do the following: You can start mysqld3.21 The server uses it from the 3.20 distribution. In this case, the new customer function mysql_errno () will not return any server errors, but only cr_unknown_error (but it is a customer error service) and the server uses the old passwd () check instead of the new one. If you are instead of using the -old-protocol option for MySQLD, you will need to do the following changes: All customer code must recompile. If you are using ODBC, you have to get a new MyoDBC 2.x driver. Script Scripts / add_long_password must run to transform the password field in the mysql.user table for char (16). All passwords in mysql.use must be reassigned (for 62 bits rather than 31-bit passwords). The table format has not changed, so you don't have to change any table. MySQL3.20.28 and above can handle new User table formats without affecting customers. If you have a MySQL version than 3.20.28, if you transform the USER table, the password will no longer work. So for security, you should first upgrade to at least 3.20.28 and then upgrade to 3.21.x. The new customer code works with a 3.20.x version of MySQLD server, so if you encounter a problem with 3.21.x, you can use the old 3.20.x server without recompiling the customer. If you don't use the - keld-protocol option for MySQLD, the old customer will make an error message: Error: protocol mismatch. Server version = 10 Client Version = 9 The new Perl DBI / DBD interface also supports the old MySQLPERL interface. If you use mysqlperl, the only change you have to do is to change the parameters of the Connect () function. The new parameters are: Host, Database, User, Password (User, and Password parameters change location). See 20.5.2 DBI interface. The following changes may affect the old application query: now Having must be specified before any ORDER BY clause. Locate () parameters are swapped. There are some new reserved words. The most famous is Date, Time and TimeStamp. 4.16.4 Upgrading to other architectures If you are using MySQL3.23, you can copy .frm, .myi, and .myd between different support of the same floating point format. (MySQL considers any byte exchange problem). MySQL ISAM Data "* .ISD" and index file "* .ism" files are dependent on the system structure and rely on OS in some cases. If you want to move your app to other machines with your current system or other machines, you should not try to move a database by simply copying files to another machine, using mysqldump.

转载请注明原文地址:https://www.9cbs.com/read-3508.html

New Post(0)