day-40mysql

epoll

# Coding: UTF-8 
# client 
# Create the client socket object 
Import socket
ClientSocket = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
 # server IP address and port number tuple 
the server_address = ( ' 127.0.0.1 ' , 1688 )
 # client connections specified IP address and port number 
clientsocket.connect ( server_address)

the while True:
     # of input data 
    Data = the raw_input ( ' Please INPUT: ' )
     IF Data == " Q " :
         BREAK 
    IF  Not Data:
       Continue 
    # client sends data 
    clientsocket.send (data.encode ( " UTF-. 8 " ))
     # client receives data 
    SERVER_DATA = clientsocket.recv (1024 )
     Print ( ' data received by the client: ' , SERVER_DATA)
 # Close client Socket 
clientsocket.close ()
Server
 # Coding: UTF-8 
Import socket, the SELECT

server = socket.socket()
server.bind(("127.0.0.1", 1688))
server.listen(5)

msgs = []


fd_socket = {server.fileno(): server}
epoll = select.epoll ()
 # registration server write-ready 
epoll.register (server.fileno (), select.EPOLLIN)

while True:
    for fd, event in epoll.poll():
        our sock = fd_socket [fd]
         Print (fd, Event)
         # returns a file descriptor needs to obtain the corresponding socket 
        IF our sock == Server:   # If the server accepts the request 
            Client, addr = server.accept ()
             # registered client write ready 
            epoll.register (client.fileno (), select.EPOLLIN)
             # add correspondence relationship 
            fd_socket [client.fileno ()] = Client

        # Read ready 
        elif Event == select.EPOLLIN:
            the Data = sock.recv (2018 )
             IF  not the Data:
                 # logout event 
                epoll.unregister (fd)
                 # close the socket 
                sock.close ()
                 # delete the correspondence between the socket 
                del fd_socket [fd]
                 Print ( " Somebody Fuck OUT ... " )
                 continue

            Print (data.decode ( " UTF-8 " ))
             # read the data needed to send data back so the next write-ready = Change event 
            epoll.modify (fd, select.EPOLLOUT)
             # recording data 
            msgs.append ((sock , data.upper ()))
         elif Event == select.EPOLLOUT:
             for Item in Msgs [:]:
                 IF Item [0] == our sock:
                    sock.send(item[1])
                    msgs.remove(item)
            # Switching events of interest to the write-ready 
            epoll.modify (fd, select.EPOLLIN)

Database concepts

  TCP is essentially a database program CS structure,

  The client connects to the server transmits to the server instruction, the operation to complete the data

Correspondence between the database and the file system

A data item name = jerry     is essentially part of a row in the data file      

A record jerry, 18, man     is essentially a row of data files   

A table               is essentially a file   

Database Folder                 

Server-side program DBMS DataBaseManagerSystem database management system database

The database server            running the DBMS computer 

Mounting

  1. Download extracting package

  2. Unzip to a directory

  3. Add the environment variable

    The system will copy the bin to add the full path to where the path of

  4. It should be self-starting as a server mysql server Requires System Services

    mysqld --install input services run to see whether success

    To delete a service sc delete mysql If you need to reinstall, then ...

    Start Service net start mysql

    Stop service net stop mysql

Server connection instruction

  TCP is the essence of the program, you must specify the ip and port, if the server is running can be omitted if the port did not turn over ip port can also be omitted in the machine

  Complete wording:

    MySQL - Hip - P port - U user name   - the p-code   
    examples: MySQL - -uroot - the p-  MySQL 5.6 default is no password
   

Change the administrator password

1. If you know the original password can use this tool mysqladmin

  mysqladmin - the p-Old Password   - U username password new password 
  instance: mysqladmin - -uroot - the p-   password 123

2. Do not know the original password is case

  Delete the password file, deletes all licensing information

  Skip authorization table we can specify allowed to ignore the authorization information when the server is started

  1. Turn off the server performs mysql mysqld --skip-grant-tables directly to the terminal

  2. No root account password

  3. Perform the update statement

  update mysql.user set password = password("123") where user="root" and host = "localhost";

 

 

 

 

  

 

Guess you like

Origin www.cnblogs.com/klw1/p/11005783.html
40